1

I am using the Git Plugin of Jenkins and have a Job that needs to commit and push some changes. The git repository I am using is hosted on GitHub. Bear with me, I am somewhat new to git.

However, when I run git status or git commit it says # Not on any branch. If I tell the plugin to use a 'branch specifier', i.e. origin/master this doesn't help.

Ho do I get the plugin to behave as if I would have done git clone on my desktop?

Jasper van den Bosch
  • 3,169
  • 4
  • 32
  • 55
  • 2
    you have run `git checkout ` probably, so now `git` is looking at that commit, but is not on the tip of any branch. If you've done work where you are now, save it with `git diff > savefile.tmp` and then checkout to the branch you want `git checkout master`, and then apply the work you've done `patch -p1 < savefile.tmp`, fix any conflicts, and `git commit` your work. Then you can push. If no work is done where you stand, then just checkout to master and push. – c00kiemon5ter Apr 16 '12 at 11:20
  • Excellent, this worked, will you make it an 'answer' so I can mark it solved? – Jasper van den Bosch Apr 16 '12 at 11:37
  • great, also created an answer ;) thanks – c00kiemon5ter Apr 16 '12 at 11:45

1 Answers1

4

you have run git checkout <some-sha> probably, so now git is looking at that commit, but is not on the tip of any branch.

If you've done work where you are now, save it with git diff > savefile.tmp
and then checkout to the branch you want: git checkout master,
and then apply the work you've done: patch -p1 < savefile.tmp,
fix any conflicts, and git commit your work.
Then you can git push.

If no work is done where you stand, then just checkout to master and push.

c00kiemon5ter
  • 16,994
  • 7
  • 46
  • 48