Skip to content

Instantly share code, notes, and snippets.

@hraban hraban/bash log
Last active Aug 9, 2019

What would you like to do?
Nice new Git feature: detect folder moves
$ 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
You can’t perform that action at this time.