Question

I am experiencing a very weird issue with git. I have a ruby app running on the server under runit management. This app has an auto update functionality. It executes git ls-remote to check if a pull and service restart is required. This part works fine, stuff executes and files are pulled, however: after the pull, all pulled changes stay in "changes not staged for commit". After execution of git reset --hard the repo has no changes staged for commit but but the local copy of the repo shows it is ahead of origin/branch by X commits.

I am not sure why this happens and how to resolve the problem. Has anyone ever experienced something similar? Any pointers appreciated.

Software is running on Ubuntu 12.04, ruby 1.9.3p448, for simplicity as a root (runit running as root). Files have correct permissions, at least that's what it looks like.

The code can be seen here: https://github.com/radekg/rgossip_app/blob/dev/lib/updater.rb Neither git pull, nor git fetch and git reset work.

*Update:*

git status returns:

root@ip-10-222-29-69:/opt/rgossip# git status
# On branch dev
# Your branch is ahead of 'origin/dev' by 1 commit.
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   README.md
#
no changes added to commit (use "git add" and/or "git commit -a")

git diff:

root@ip-10-222-29-69:/opt/rgossip# git diff
diff --git a/README.md b/README.md
index e7136db..e9d7360 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,3 @@
 Managing Chef boxes with gossip.

-More description soon. Testing.
\ No newline at end of file
+More description soon.
\ No newline at end of file

And that's for this commit: https://github.com/radekg/rgossip_app/commit/176e7cf764ff9ea0299ef75a21bb79a5bea11406

After executing git reset --hard I get:

root@ip-10-222-29-69:/opt/rgossip# git reset --hard
HEAD is now at 176e7cf Testing with commits seems stupid.
Was it helpful?

Solution

A git pull is basically a git fetch followed by a git merge. If you've done a merge you'll be ahead of origin/branch since that merge doesn't exists on origin/branch.

You really shouldn't use merge in automatic script, that's a command that might require human interaction, you should use git fetch and git checkout.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top