Bhanuchander Udhayakumar
Bhanuchander Udhayakumar

Reputation: 1621

difference between git --git-dir checkout and git checkout

git checkout acts differently for using option --git-dir.

Commands :

  1. inside_gitdir$ git checkout remote/branch
  2. outside_gitdir$ git --git-dir=/path/.git checkout remote/branch

Here command 1 works well and checking out. but the command 2 shows to move files like :

error: The following untracked working tree files would be overwritten by checkout:
someFiles

Please move or remove them before you can switch branches.
Aborting

I thought both the commands are running in same way. But,

Upvotes: 1

Views: 235

Answers (1)

vvassilev
vvassilev

Reputation: 316

I ran into the same issue.

It seems to work if you do: git --git-dir=/path/.git --work-tree=/path/ checkout remote/branch

Upvotes: 1

Related Questions