Re: GIT not pushing changes instead checked in changes are overwritten by git checkout once build starts

218 views
Skip to first unread message

Kevin Fleming (BLOOMBERG/ 731 LEXIN)

unread,
Feb 13, 2014, 1:01:20 PM2/13/14
to jenkins...@googlegroups.com
If you commit changes on a detached HEAD (this is a Git term that means you are not on any branch), then nothing can be pushed. Only branches (references) can be pushed to another location.

Your build job needs to check out a specific branch, modify it, then push it back.

----- Original Message -----
From: jenkins...@googlegroups.com
To: jenkins...@googlegroups.com
At: Feb 13 2014 12:59:05
Hi

Please help me in this regards.

i dont know why after git commit the status revert to old revision and push does not occur.

+ /usr/bin/git add .
+ /usr/bin/git status
# Not currently on any branch.
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   xxxx1.css
#       new file:   xxxx2.css
#       new file:   xxxx3.css
 
+ /usr/bin/git commit -am 'checked in from jenkins'
[detached HEAD 07c00f4] checked in from jenkins
 45 files changed, 11897 insertions(+), 3 deletions(-)
 create mode 100644 xxxx1.css
 create mode 100644 xxxx2.css
 create mode 100644 xxxx3.css

+ /usr/bin/git status
# Not currently on any branch.
nothing to commit (working directory clean)
+ /usr/bin/git push
Everything up-to-date


I dont understand what happens after commit and before push, its not working executing shell inside jenkins or manually putting commands into jenkins.

Require assistance, please.

Jyotir


On Thursday, 13 February 2014 19:54:20 UTC+5:30, jyotir bhandari wrote:
Hi

I am newbie to jenkins, and since morning I am trying to push changes to git repositories, but after git commit, it just does not executes git push command in pre build scm.

I have tried tit publisher in post script but then build process just checks-out stable release available to him and after that git publish sticks to it, it commit changes are overwritten again and again.

Note : I am not using github, i have my own git server.

Please suggest as to how to get code checked in via jenkins.

Regards
Jyotir
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

jyotir bhandari

unread,
Feb 13, 2014, 1:29:32 PM2/13/14
to jenkins...@googlegroups.com, Kevin Fleming
Thanks got that working, changed my .git/HEAD in jenkins workspace with file content  ref: refs/heads/master

Jyotir

Daniel Serodio

unread,
Oct 21, 2014, 2:14:23 PM10/21/14
to jenkins...@googlegroups.com, kpfl...@bloomberg.net
What's the "proper" way to achieve this, instead of manipulating .git/* files like Jyotir did? I don't understand why Jenkins doesn't use remote tracking branches like most Git integrations do.

Regards,
Daniel Serodio

Mark Waite

unread,
Oct 21, 2014, 4:10:15 PM10/21/14
to jenkins...@googlegroups.com
Kevin described the proper way.  In the job definition, select "Additional Behaviours" and the item "Check out to specific local branch" if you need a local branch in the repository.

I believe the Jenkins git plugin does not use a remote tracking branch by default because it assumes most continuous integration jobs do not need to push changes.  If you don't need to push changes, then checkout to a detached head meets the need without the complexity of managing branches.

Mark Waite

For more options, visit https://groups.google.com/d/optout.



--
Thanks!
Mark Waite
Reply all
Reply to author
Forward
0 new messages