git-add

Removing multiple files from a Git repo that have already been deleted from disk

南楼画角 提交于 2019-11-26 03:22:46
问题 I have a Git repo that I have deleted four files from using rm ( not git rm ), and my Git status looks like this: # deleted: file1.txt # deleted: file2.txt # deleted: file3.txt # deleted: file4.txt How do I remove these files from Git without having to manually go through and add each file like this: git rm file1 file2 file3 file4 Ideally, I\'m looking for something that works in the same way that git add . does, if that\'s possible. 回答1: For Git 1.x $ git add -u This tells git to

Undo git reset --hard with uncommitted files in the staging area

让人想犯罪 __ 提交于 2019-11-26 01:05:58
问题 I am trying to recover my work. I stupidly did git reset --hard , but before that I\'ve done only get add . and didn\'t do git commit . Please help! Here is my log: MacBookPro:api user$ git status # On branch master # Changes to be committed: # (use \"git reset HEAD <file>...\" to unstage) # modified: .gitignore ... MacBookPro:api user$ git reset --hard HEAD is now at ff546fa added new strucuture for api Is it possible to undo git reset --hard in this situation? 回答1: You should be able to

Undo git reset --hard with uncommitted files in the staging area

早过忘川 提交于 2019-11-26 00:27:29
I am trying to recover my work. I stupidly did git reset --hard , but before that I've done only get add . and didn't do git commit . Please help! Here is my log: MacBookPro:api user$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # modified: .gitignore ... MacBookPro:api user$ git reset --hard HEAD is now at ff546fa added new strucuture for api Is it possible to undo git reset --hard in this situation? Mark Longair You should be able to recover any files back that you added to the index (e.g, as in your situation, with git add . )

Difference between “git add -A” and “git add .”

拜拜、爱过 提交于 2019-11-25 22:19:47
问题 The command git add [--all|-A] appears to be identical to git add . . Is this correct? If not, how do they differ? 回答1: This answer only applies to Git version 1.x . For Git version 2.x, see other answers. Summary: git add -A stages all changes git add . stages new files and modifications, without deletions git add -u stages modifications and deletions, without new files Detail: git add -A is equivalent to git add .; git add -u . The important point about git add . is that it looks at the

How can I add an empty directory to a Git repository?

China☆狼群 提交于 2019-11-25 22:15:45
问题 How can I add an empty directory (that contains no files) to a Git repository? 回答1: Another way to make a directory stay (almost) empty (in the repository) is to create a .gitignore file inside that directory that contains these four lines: # Ignore everything in this directory * # Except this file !.gitignore Then you don't have to get the order right the way that you have to do in m104's solution. This also gives the benefit that files in that directory won't show up as "untracked" when you

Removing multiple files from a Git repo that have already been deleted from disk

一笑奈何 提交于 2019-11-25 20:00:02
I have a Git repo that I have deleted four files from using rm ( not git rm ), and my Git status looks like this: # deleted: file1.txt # deleted: file2.txt # deleted: file3.txt # deleted: file4.txt How do I remove these files from Git without having to manually go through and add each file like this: git rm file1 file2 file3 file4 Ideally, I'm looking for something that works in the same way that git add . does, if that's possible. For Git 1.x $ git add -u This tells git to automatically stage tracked files -- including deleting the previously tracked files. For Git 2.0 To stage your whole