On 12/10/2013 11:42 PM, Ahmed Charles wrote:
To: boost@lists.boost.org From: eldiener@tropicsoft.com Date: Tue, 10 Dec 2013 22:19:30 -0500 Subject: Re: [boost] [git] The any library does not pull cleanly because of a forced update on develop and master.
It sounded like in git one must continuously specify --follow after the move with each commit in order to preserve history, or was the person who said that mistaken ?
Intuitively to me once one uses a command to tell git that a file in a repository is being moved/renamed to something else in the repository and that the previous history should follow that file, then one should always be able to see the full history of that file both before ane after the move/rename.
It's just as painful in SVN to view the contents of a past file through a copy/move/delete, until you get experienced with peg revisions or you use an interactive repository browser to view the whole tree as it appeared in the past.
(And, once you know a commit hash prior to the move, you can use "gitk 5a0d9820ac6bd4068a1fa3075d45904ed5341675" to view that revision and its history, just like you can with SVN.)
I do not think that one should ever have to know some abstruse commit number in order to see the history of a file in a repository.
There seems to be some amount of misinformation/confusion in this thread, so here's an example:
== Create the repository. ~ $ mkdir file ~ $ cd file/ ~/file $ git init Initialized empty Git repository in ~/file/.git/ ~/file (master #) $ git status # On branch master # # Initial commit # nothing to commit (create/copy files and use "git add" to track)
== Add a file and make a series of commits with changes to it. ~/file (master #) $ echo "line 1" >> file.txt ~/file (master #%) $ git add file.txt ~/file (master #) $ git ci -m "line 1" [master (root-commit) d29d848] line 1 1 file changed, 1 insertion(+) create mode 100644 file.txt ~/file (master) $ echo "line 2" >> file.txt ~/file (master *) $ git ci -a -m "line 2" [master 7c0ee29] line 2 1 file changed, 1 insertion(+) ~/file (master) $ echo "line 3" >> file.txt ~/file (master *) $ git ci -a -m "line 3" [master c7b1f4c] line 3 1 file changed, 1 insertion(+)
== Move the file to a new name. ~/file (master) $ git mv file.txt other.txt ~/file (master +) $ git st # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # renamed: file.txt -> other.txt # ~/file (master +) $ git ci -m "move file.txt to other.txt" [master 5e581f3] move file.txt to other.txt 1 file changed, 0 insertions(+), 0 deletions(-) rename file.txt => other.txt (100%)
== Add another change to the file under it's new name. ~/file (master) $ echo "line 4" >> other.txt ~/file (master *) $ git ci -a -m "line 4" [master c4a8b48] line 4 1 file changed, 1 insertion(+)
== Run git log, which shows all of the commits. ~/file (master) $ git log commit c4a8b48fbf38a9b06376b30a36a76b6a674384a9 Author: Ahmed Charles
Date: Tue Dec 10 20:19:41 2013 -0800 line 4
commit 5e581f3b61a759b8e572e7fe4f1a2081bcb7aed8 Author: Ahmed Charles
Date: Tue Dec 10 20:19:19 2013 -0800 move file.txt to other.txt
commit c7b1f4ce30b199794e29a151642267d84842d03b Author: Ahmed Charles
Date: Tue Dec 10 20:18:31 2013 -0800 line 3
commit 7c0ee297b1f76c73badbc07b5bf426f5cb521e35 Author: Ahmed Charles
Date: Tue Dec 10 20:17:54 2013 -0800 line 2
commit d29d848569c0d620e45d6e18d10650da1c0cf1d4 Author: Ahmed Charles
Date: Tue Dec 10 20:17:25 2013 -0800 line 1
== Run git log <file>, which shows commits to that file, note, it only shows the last two. ~/file (master) $ git log other.txt commit c4a8b48fbf38a9b06376b30a36a76b6a674384a9 Author: Ahmed Charles
Date: Tue Dec 10 20:19:41 2013 -0800 line 4
commit 5e581f3b61a759b8e572e7fe4f1a2081bcb7aed8 Author: Ahmed Charles
Date: Tue Dec 10 20:19:19 2013 -0800 move file.txt to other.txt
== Run git log --follow <file>, which shows commits to that file and follows the file through moves. ~/file (master) $ git log --follow other.txt commit c4a8b48fbf38a9b06376b30a36a76b6a674384a9 Author: Ahmed Charles
Date: Tue Dec 10 20:19:41 2013 -0800 line 4
commit 5e581f3b61a759b8e572e7fe4f1a2081bcb7aed8 Author: Ahmed Charles
Date: Tue Dec 10 20:19:19 2013 -0800 move file.txt to other.txt
commit c7b1f4ce30b199794e29a151642267d84842d03b Author: Ahmed Charles
Date: Tue Dec 10 20:18:31 2013 -0800 line 3
commit 7c0ee297b1f76c73badbc07b5bf426f5cb521e35 Author: Ahmed Charles
Date: Tue Dec 10 20:17:54 2013 -0800 line 2
commit d29d848569c0d620e45d6e18d10650da1c0cf1d4 Author: Ahmed Charles
Date: Tue Dec 10 20:17:25 2013 -0800 line 1
So, to be accurate, the complaint is that '--follow' is required when running git log on a file which has been moved at some point in it's history.
Thanks for the clarification. It makes me feel better about using git to see that it does keep the history when you move a file. I could not imagine that it did not.