Last active
August 9, 2019 10:40
-
-
Save hraban/bb2a8c92924fcd35d7681cb05986cada to your computer and use it in GitHub Desktop.
Nice new Git feature: detect folder moves
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cd /tmp | |
| $ mkdir test | |
| $ cd test | |
| $ git init | |
| Initialized empty Git repository in /private/tmp/test/.git/ | |
| $ git commit --allow-empty -m root | |
| [master (root-commit) 6814cc9] root | |
| $ mkdir foo | |
| $ echo a > foo/a | |
| $ git add foo | |
| $ git commit -m a | |
| [master f72297b] a | |
| 1 file changed, 1 insertion(+) | |
| create mode 100644 foo/a | |
| $ git checkout -b b | |
| Switched to a new branch 'b' | |
| $ echo b > foo/b | |
| $ git add foo | |
| $ git commit -m b | |
| [b ef4fa31] b | |
| 1 file changed, 1 insertion(+) | |
| create mode 100644 foo/b | |
| $ git checkout master | |
| Switched to branch 'master' | |
| $ mkdir src | |
| $ mv foo src/ | |
| $ git add src foo | |
| $ git commit -v -m 'Move foo/ to src/foo/' | |
| [master ce24248] Move foo/ to src/foo/ | |
| 1 file changed, 0 insertions(+), 0 deletions(-) | |
| rename {foo => src/foo}/a (100%) | |
| $ git checkout b | |
| Switched to branch 'b' | |
| $ git merge master | |
| CONFLICT (file location): foo/b added in HEAD inside a directory that was renamed in master, suggesting it should perhaps be moved to src/foo/b. | |
| Automatic merge failed; fix conflicts and then commit the result. | |
| $ git status | |
| On branch b | |
| You have unmerged paths. | |
| (fix conflicts and run "git commit") | |
| (use "git merge --abort" to abort the merge) | |
| Changes to be committed: | |
| deleted: foo/b | |
| renamed: foo/a -> src/foo/a | |
| Unmerged paths: | |
| (use "git add <file>..." to mark resolution) | |
| added by us: src/foo/b | |
| $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment