user1852176
user1852176

Reputation: 455

git pushing wrong repository to bitbucket

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?

Upvotes: 1

Views: 1070

Answers (1)

VonC
VonC

Reputation: 1324278

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.

Upvotes: 1

Related Questions