git-stage

Staging Deleted files

岁酱吖の 提交于 2019-11-28 13:09:07
问题 Say I have a file in my git repository called foo . Suppose it has been deleted with rm (not git rm ). Then git status will show: Changes not staged for commit: deleted: foo How do I stage this individual file deletion? If I try: git add foo It says: 'foo' did not match any files. 回答1: Use git rm foo to stage the file for deletion. (This will also delete the file from the file system, if it hadn't been previously deleted. It can, of course, be restored from git, since it was previously

Git: list only “untracked” files (also, custom commands)

£可爱£侵袭症+ 提交于 2019-11-26 18:00:33
Is there a way to use a command like git ls-files to show only untracked files? The reason I'm asking is because I use the following command to process all deleted files: git ls-files -d | xargs git rm I'd like something similar for untracked files: git some-command --some-options | xargs git add I was able to find the -o option to git ls-files , but this isn't what I want because it also shows ignored files. I was also able to come up with the following long and ugly command: git status --porcelain | grep '^??' | cut -c4- | xargs git add It seems like there's got to be a better command I can

Git: list only “untracked” files (also, custom commands)

孤人 提交于 2019-11-26 08:57:35
问题 Is there a way to use a command like git ls-files to show only untracked files? The reason I\'m asking is because I use the following command to process all deleted files: git ls-files -d | xargs git rm I\'d like something similar for untracked files: git some-command --some-options | xargs git add I was able to find the -o option to git ls-files , but this isn\'t what I want because it also shows ignored files. I was also able to come up with the following long and ugly command: git status -

How do I show the changes which have been staged?

帅比萌擦擦* 提交于 2019-11-26 03:31:05
问题 I staged a few changes to be committed; how can I see the diff of all files which are staged for the next commit? I\'m aware of git status, but I\'d like to see the actual diffs - not just the names of files which are staged. I saw that the git-diff(1) man page says git diff [--options] [--] […] This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell git to further add to the index but you