Reputation: 18579
I sync my development code on 2 machines using a git bare repository on a usb drive (followed these steps git setup for backup & sync between 2 computers).
I push my changes to the bare repo on the USB and then fetch & merge on the other machine.
My understanding was that these 2 commands are same, but their output is different. The log shows that the first command creates a new branch.
Method 1
git fetch origin
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /usb/backup/code
* [new branch] master -> origin/master
Method 2
git fetch /usb/backup/code.git
From /usb/backup/code
* branch HEAD -> FETCH_HEAD
Upvotes: 1
Views: 632
Reputation: 1329122
That is because:
git fetch origin
is the same, when git remote is configured by default, than
git fetch origin +refs/heads/*:refs/remotes/origin/*
It will tell Git what to fetch and where to store the resulting commit.
But:
git fetch path/to/.git
means you don't benefit from the default refspec setting origin +refs/heads/*:refs/remotes/origin/*
, which means you are doing:
git fetch path/to/.git HEAD:
(you fetch the remote HEAD
without specifying where to put it).
The resulting commit is stored in FETCH_HEAD
ref.
See "Having a hard time understanding git-fetch
" for more.
(and "git fetch
with path instead of remote")
Upvotes: 4