If I have n commits, how can I branch from the n-3 commit?
I can see the hash of every commit.
First, checkout the branch that you want to take the specific commit to make a new branch. Then look at the toolbar, select Repository > Branch ... the shortcut is Command + Shift + B. And select the specific commit you want to take. And give a new branch name then create a branch!
To pull up a list of your commits and their associated hashes, you can run the git log command. To checkout a previous commit, you will use the Git checkout command followed by the commit hash you retrieved from your Git log.
Use the git switch - (Or git checkout - ) to switch to the previous branch you were working with. This is pretty similar to the cd - command, which is used to switch to the previous directory.
You can create the branch via a hash:
git branch branchname <sha1-of-commit>
Or by using a symbolic reference:
git branch branchname HEAD~3
To checkout the branch when creating it, use
git checkout -b branchname <sha1-of-commit or HEAD~3>
To do this on github.com:
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