开发者

Tell Git: I Like It Like This

开发者 https://www.devze.com 2023-02-18 07:55 出处:网络
Sometimes I like to move a lot of files around in the OS X Finder, delete some, add some, modify some – more than 30 changes.

Sometimes I like to move a lot of files around in the OS X Finder, delete some, add some, modify some – more than 30 changes.

As things are, I need to go through and "git rm" every file I removed and "git mv" every file I moved after the fact when I'm not sure if I "rm'd" or "mv'd" and I don't get Bash completion because the file is gon开发者_如何学编程e.

When I'm done with this, I'd like to be able to say to Git: I like it like this, let's commit all these changes.

Is there some way to do this?


Use git add -A to add the changes, then git commit to commit it.

Compared to git commit -a, this will really take the working tree as it is. It will handle new, moved, and renamed files while git commit -a won't. git commit -a ignores new files and treats moved and renamed files as deleting the files (since the files in the new location are considered new files, which are ignored).


I think you can do

 git add .

To add all the new files (even the ones that have been moved). And

 git add -u .

For the ones that have been deleted (or moved).

Git will figure out by itself the ones that were moved. I would be surprised there is not a way to combine this into one single command, but that's what I usually do...

0

精彩评论

暂无评论...
验证码 换一张
取 消