I've created a branch b1
and I made some changes on it and I push it to the remote repository:
git branch b1 git checkout b1 git add newfile.txt git commit -m "adding a new file" git push origin b1
On an other machine which is connected to the remote repository, I tried to pull the branch without merge it with master:
$git branch *master $git pull origin b1 remote: Counting objects: 4, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From sl*******02:/opt/git/projet1 * branch b1 -> FETCH_HEAD Updating fca3b48..1d96ceb Fast-forward newfile.txt | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 newfile.txt $git branch *master
what I expected:
$git branch *master b1
You can use git fetch origin b1 to only fetch remote branch without merge. Merge execute because you was on master branch, and not your local b1 branch.
If you have a single remote repository, then you can omit all arguments. just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.
You can use git fetch origin b1
to only fetch remote branch without merge.
See : https://git-scm.com/docs/git-fetch
Basically git pull
is a shortcut to git fetch && git merge
Merge execute because you was on master branch, and not your local b1 branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With