Vsevolod Kaimashnikov
Vsevolod Kaimashnikov

Reputation: 23

Restore missed git commit on remote

Please, help. I made a mistake:

I move branch from commit a to commit b.

And now commit a is missed or detached.

When I'm trying:

set tag on gitlab on commit a

or

git checkout a && git checkout -b branch-name && git push origin branch-name on local mashine

I get error

remote: fatal: ambiguous argument '1fcdaca7723d5939178c2557254c124aee30ec2d~1': unknown revision or path not in the working tree. remote: Use '--' to separate paths from revisions, like this: remote: 'git <command> [<revision>...] -- [<file>...]'

How it can be fixed?

Upvotes: 1

Views: 39

Answers (1)

larsks
larsks

Reputation: 312128

If you still have the commit locally, you can simply create a new branch referencing it:

git checkout -b mybranch 1fcdaca7723d5939178c2557254c124aee30ec2d

And now you can push that branch to gitlab or wherever.

Upvotes: 1

Related Questions