Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git checkout branch doesn't change working directory

I am not exactly sure how to phrase this question, as I am new to git. One of my coworkers was working on a feature in a branch called "rotation." I wanted to make use of the code he wrote, so I ran git checkout rotation. The main difference between master and rotation branches is that the rotation branch has an extra subdirectory titled rotation/. However, after running git checkout, this subdirectory did not show up in my working directory. How do I get this subdirectory to show up? I did some googling and found that git doesn't make changes to your working directory when you git checkout a branch if those changes would conflict with tracked changes in your working directory. However, this is not the case here, at least for the rotation/ subdirectory, as it does not even exist in master. So why doesn't this subdirectory show up? How do I get it to?

like image 567
Terry Martin Avatar asked Oct 28 '25 12:10

Terry Martin


2 Answers

Simply checking out the branch isn't enough to get remote changes to your machine. You must use git pull or git fetch.

Here is a useful diagram you can use as a reference.

like image 126
sunw Avatar answered Oct 30 '25 01:10

sunw


Have you tried git pull origin rotation? The form should be git pull <remote> <branchname>.

like image 24
Nacev Avatar answered Oct 30 '25 01:10

Nacev