Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch git branch not updating files

Tags:

git

git-branch

I have created a new branch and added some files.

Locally I use tortoise GIT and when I switch to the new branch, the files are updated.

On my production server using CLI, when I switch to the new branch with git checkout mynewbranch, the files are not updated.

When I switch with git checkout origin/mynewbranch, the files are updated but i get the following message:

You are in 'detached HEAD' state. You can look around, make
experimental changes and commit them, and you can discard any commits     
you make in this state without impacting any branches by performing 
another checkout.

Why is this?

like image 363
Asa Carter Avatar asked Dec 18 '22 22:12

Asa Carter


1 Answers

It appears as if you already have a local branch with the name mynewbranch but this branch does not have the recent changes that you're looking for. Those changes do exist in the origin, however. Because of this, when you git checkout origin/mynewbranch you are able to see the changes. If you want to pull these changes into your local mynewbranch branch, issue the following commands:

git checkout mynewbranch
git pull . origin/mynewbranch
like image 175
mkrufky Avatar answered Dec 30 '22 01:12

mkrufky