2

Everytime a commit is pushed in a Stash repository, a build in triggered in our build system. However, sometimes, people do a rebase of that commit, so it is not contained in a branch anymore.

Our build system does a clone of the repository, then the command:

git reset --hard <sha>

However, the command fails since the clone seems to get the list of commits of the branch, and the commit is not contained in the branch anymore, even if the commit still exists when trying to access it in Stash.

Is there a way to fetch that specific commit so that the system can build the code from the commit that is orphaned?

Amaranth
  • 2,433
  • 6
  • 36
  • 58
  • See http://stackoverflow.com/questions/25416003/clone-a-git-repository-and-keep-unreachable-commits – jub0bs Aug 13 '15 at 18:24
  • Step 3 of that answer, the one I think I need, does not work. If I go in Stash, the url: 'stash-server.org/users/MyUser/repos/MyRepo/commits/cbdb62a4a8f0c81dff9a27c90edb26106c96fcc6' works, I can see the commit information and see that it is associated to "no branches". However, after doing a git clone command (I also tried doing a bare repository), a simple git show command with the sha I want gives me an error, the git branch command too. If I enter the command: 'git branch -r --contains cbdb62a4a8f0c81dff9a27c90edb26106c96fcc6', It tells me no such commit exists... – Amaranth Aug 13 '15 at 20:20
  • Not sure if this is right, but I think I used the wrong word. The commit might not be 'orphaned'. I think the rebase makes it so that the commit does not exist in GIT anymore, but Stash seems to be keeping the history of that commit anyway. Since I am trying to get the commit from a GIT command, what I am trying to do might be impossible (since it exists only in Stash). – Amaranth Aug 25 '15 at 22:19
  • The suggested answer does not work for me, since I am not the maintainer of the server (BitBucket). I need to get to an orphaned commit. Nobody has neither a copy of that commit, nor of the branch on which it was on before that branch was deleted. I know that commit is in BB's history. But I can't get to it with fetch/clone/pull. Please help! – XedinUnknown Sep 21 '15 at 14:13

0 Answers0