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
git branch
lists local branches, since you've never checked outb1
it only resides in the remote, usegit branch -a
to list this as well. In order to get it as a local branch, check it out withgit checkout b1
, this will create a local branch out of the remote branch and set up upstream mapping between them.error: pathspec 'b1' did not match any file(s) known to git.
git fetch
without parameters first, orgit fetch origin