1

I just realized that for about a week now my git pushes are not actually going through to my repository on bitbucket. I'm using Mac and have GitX locally which is showing my commits from the past week that have not made it to bitbucket.

When I try git push it says "Everything up-to-date". I've tried git push origin master, git push --all, git push origin --all, and git push origin master:master all of them say "up to date".

As I stated, I use GitX locally to view the commits/files. The directory of the project I'm working in is /Applications/XAMPP/xamppfiles/hdtocs/serve, but I noticed in gitx that there is a repository labeled /Applications/XAMPP/xamppfiles/hdtocs/serve1. I checked the commits in serve1 and sure enough, it matches up with the one on bitbucket. I have no idea how/what I did, but it's just an older version of the serve repository.

Despite commits adding correctly locally to the serve repository, it seems like git is trying to push serve1 which explains why it says no updates. I made sure that I'm in the serve directory with cd /Applications/XAMPP/xamppfiles/hdtocs/serve

What can I do to get the correct repository to push?

user1852176
  • 455
  • 1
  • 9
  • 29

1 Answers1

1

Make sure you aren't in a DETACHED HEAD mode.

In that case, your local refs/heads aren't modified by a local commit, which means any kind of push will result in an "Everything up-to-date" error message.

If that is the case, you can create a local branch referring the current (detached head), or reset an existing local branch to it, and then a push will work.

To recover from your situation, you should create a branch that points to the commit currently pointed to by your detached HEAD:

git checkout -b temp

This will reattach your HEAD to the new temp branch.

You can then merge, if you want that branch to the branch you wanted to use (it should be a fast-forward merge).

git checkout local_branch
git merge temp

If you were only working with master (as your only local branch)

git checkout master
git merge temp

Check the state of your branches with:

git branch -avvv

And you can then push.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • you're right, the head is detached. Which would you suggest doing? How can I reset an existing local branch to it...for that matter what is it? The bitbucket repository? – user1852176 Oct 11 '13 at 05:35
  • @user1852176 the link I mention in my answer is a good read. I have edited the answer to include the relevant extracts. I presume in your case, you must have been working with `master` as your only local branch. – VonC Oct 11 '13 at 05:37
  • thanks so much for the help. I was able to create the temp branch, but when I type `git checkout local_branch` it says error: pathspec 'local_branch' did not match any file(s) known to git. Am I supposed to do `git checkout temp` instead? Using `git branch -avvv' I can see 3: master, temp and remotes/origin/master – user1852176 Oct 11 '13 at 05:46
  • @user1852176 I though it was obvious 'local_branch' was a **template name** that you would need to replace by whatever branch you should be using in your repo. It is a generic answer made to be adapted, by you, to the specifics of your repo. In your case: `git checkout master`. – VonC Oct 11 '13 at 06:07
  • now that you mention it, that is quite obvious. I haven't done too much digging around in git so I'm still figuring commands and terms. Thanks again, it worked! – user1852176 Oct 11 '13 at 06:18