📅  最后修改于: 2023-12-03 14:41:25.167000             🧑  作者: Mango
As a programmer, you may need to create a new branch in Git from a specific commit. This can be done easily using the Git command-line interface (CLI).
Here are the steps to create a new branch from a specific commit:
git log --oneline --decorate --graph
This command will display the commit logs, decorated with the branch names and in a graphical format. Note the commit hash of the commit you wish to create a new branch from.
git branch <new-branch> <commit-hash>
Replace <new-branch>
with the name of the new branch you wish to create, and <commit-hash>
with the actual commit hash of the commit you want to create the branch from.
git checkout <new-branch>
This will move the head to the newly created branch.
git push -u origin <new-branch>
This will enable other developers to track your new branch.
Creating a new branch in Git from a specific commit can be done quickly using the Git CLI. By following the steps outlined above, you can create a new branch and push it to the remote repository in just a few commands.