Reputation: 11905
I have git 1.8.3 installed on my Windows 8.1 PC.
I'm using GitHub and its companion, GitHub for Windows version 1.2.3.0.
As you can tell from the question, I'm new to git.
Currently, my repo has only one branch (“master”). I need to go back to an earlier commit and check it out on a new branch to make some changes. This is easy to do if I want the checkout to modify my current working directory, but I really want to keep my current (“master”) working directory undisturbed and do the checkout to a new working directory so that I can work on both versions (each on its own branch) simultaneously.
Is there an easy way to check out a branch (in this case, it would be a newly created branch, but it could just as well be an existing branch) to a new working directory? Or is the "correct" way to do this to create a new clone of the GitHub repo in a new working directory, then do the desired checkout in that directory?
Upvotes: 2
Views: 486
Reputation: 19564
If you want to work on multiple branches from one local git repository, I recommend you use git stashing
. It is a very convenient way to temporarily save some work on one branch to the side so you can work on something else.
Upvotes: 0
Reputation: 30330
Or is the "correct" way to do this to create a new clone of the GitHub repo in a new working directory, then do the desired checkout in that directory?
If you really want to work on both simultaneously, yes.
git clone your-git-url new-directory
cd new-directory
git checkout -b new-branch old-commit-hash
Upvotes: 2