Thomas5631
Thomas5631

Reputation: 244

Set a git SHA manually / update GitLab commit links for archived merge

I have a large project which has a closed merge request. On the merge request, there are links to all of the commits which were involved in the merge. After merging, the relevant branch was deleted.

Due to rebasing, the commit SHA's on the archived merge request no longer match with those on the master branch (or any currently available branches), and I would like to have appropriate links.

My questions:

Can I manually set a git commit SHA, and if so, how?

If not, can I adjust the commit link (GitLab) so that the merge request now points to the newly calculated commit SHA's?

Upvotes: 0

Views: 128

Answers (2)

yupengzhang
yupengzhang

Reputation: 54

I don't know whether I have your core question that:

1 your merged branch has been deleted 2 your merged commit has been rebased 3 you want the merge commit link to the commit on the deleted branch ?

If you did delete the merged branch on local, you can try git reflog to revert you last commit, but if the action happened long enough and has been pushed to the server, OK, you'll not make it.

But what's your real requirement, why you want to make that.

Upvotes: 0

jbu
jbu

Reputation: 16131

You cannot manually set a SHA-1 sum, as it is computed and is a function of your commit. In other words, if you change your SHA-1 sum it won't match the commit's contents and would therefore be inconsistent.

There are techniques to try to deliberately modify your application in non-harmful ways until you get a desired hash, however, they are very unlikely to succeed. One technique is to insert sequences of whitespace characters in a document until the desired hash is created. This can take a very long time especially with longer and more effective hash algorithms.

Upvotes: 2

Related Questions