git create branch from commit code example
Example 1: git create branch with specific commit
git branch develop 04c900c
git push --set-upstream origin develop
git checkout develop
Example 2: commit to a new branch
git checkout -b your-new-branch
git add <files>
git commit -m <message>
First, checkout your new branch.
Then add all the files you want to commit to staging.
Lastly, commit all the files you just added.
You might want to do a git push origin your-new-branch afterward so your changes show up on the remote.
Example 3: how to commit a branch in git
git commit -m "added my github name"
Example 4: git branch from commit
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>
Example 5: create a branch from old commit
git log --author=<name or email> // get user (press enter to find exact one)
git checkout -b justin a9c146a09505837ec03b //create and checkout branch