Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pull remote branch without merge

Tags:

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 
like image 872
Carole Avatar asked May 23 '18 10:05

Carole


People also ask

How do I pull a remote branch without merging?

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.

How do I pull a specific branch from a remote?

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.


1 Answers

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.

like image 184
Calumah Avatar answered Oct 10 '22 08:10

Calumah