Reputation: 2732
I'm using the following Git command in order to create a new remote branch:
git push origin origin:refs/heads/new_branch_name
I wish that the new branch will start from an old commit,
How can I do that? (I've tried some different methods, though failed)
Thank you.
Upvotes: 20
Views: 12397
Reputation: 855
There is a one-liner:
git push origin <id-of-commit>:refs/heads/<name-of-remote-branch>
Upvotes: 5
Reputation: 39
if you want create a new branch from a specific commit, execute command git log
or gitk
, copy the id and execute command git checkout ID COMMIT
, then commit and push. This link can help you.
Upvotes: 2
Reputation: 24337
git checkout -b new_branch_name
git reset --hard <old_commit_id>
git push origin new_branch_name
Upvotes: 35