I am using the GitHub application for Windows, and it's working great. However, I'm confused how I can work on multiple branches at the same time on my local files.
Let's say that I cloned a repository to C:\github, if I create a new branch nothing changes in my file structure. Meaning that whenever I change a file, it should also change for the master branch, right?
How can I have two branches locally on my machine that I can work on seperately, without having any conflicts. So that when I change file X in branch A, X hasn't changed in the master branch?
The behavior you're asking for is the default behavior for git. When you create a new branch, you're effectively saying that you want to fork the development history from the point where you create the branch. Once you checkout
a branch, all work done on files will happen in that branch.
To make this more concrete, imagine you have cloned a repository and just have one branch called master
. To create and checkout a new branch, you would do:
git checkout -b new_branch
Now, you would modify file X as desired, add
it, commit
it, and if you want to share it with others, push
it. Now, to see the version of X before the changes you made, simply return to the master
branch:
git checkout master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With