Tyrion Lannister
Tyrion Lannister

Reputation: 270

How to push an older checked out commit to github

I checked out one of my older commits with git checkout. Now I want to push this commit but keep getting errors. After I try to git push:

enter image description here

I tried:

git push origin HEAD:new branch

But that didn't work. I've tried a lot of combinations of stackoverflow answers but can't figure it out.

Upvotes: 0

Views: 346

Answers (1)

VonC
VonC

Reputation: 1323573

Simply create a new branch where you are:

git checkout -b newBranch
git push -u origin newBranch

That will reference the detached HEAD (since checkout a commit means detached HEAD) and allows you to push said branch.

Upvotes: 4

Related Questions