Pull Remote Branch Without Merge
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...
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
6 Answers
You can use git fetch origin b1 to only fetch remote branch without merge.
See :
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.
You are actually asking two questions:
- in the title - how to pull without merge (I came here for this question, originally;)
- in the description - how to check out a branch without merging in to master
Pull remote branch without merge
# Assuming you are on wanted branch (b1) already
git pull --rebase
No merge, just rebase.