1

How could I easily find a branch with a particular commit and checkout to it with rugged so that I won't end with 'detached HEAD' state?

Step by step I'd like to:

  • Clone repository
  • repo.lookup commithash to return catch exception and exit if Rugged::OdbError: Object not found happens
  • find a branch containing given commit hash
  • checkout to that branch
apaderno
  • 28,547
  • 16
  • 75
  • 90
mieciu
  • 448
  • 3
  • 7
  • And as you implemented the steps you outlined in your question, what have you observed? – Holger Just May 18 '15 at 11:48
  • I have no idea how to do the third step. Checking out a commit with force strategy leaves me in detached HEAD state which I would like to avoid – mieciu May 18 '15 at 12:04
  • What do you mean by that third step? Do you know that you have a barnch at a particular commit and would like to find it? If you checkout a commit, you *have* to detach HEAD. If you want to checkout a branch, you must pass specify the branch/ref. – Carlos Martín Nieto May 18 '15 at 15:15
  • I would like to do something like: git branch --contains * devel master release-branch – mieciu May 27 '15 at 12:50

1 Answers1

0

I had the same problem but in my case was when I was trying to run a script on CircleCi, so to avoid the error you should run [[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow, maybe in your case you just should run just git fetch --unshallow and then run the task that you want.