tags:

views:

63

answers:

1
+1  Q: 

Git Push Issues

I have a repository that I freshly cloned from github. The address is git://github.com/JoshClose/CsvHelper.git if you want to try this out. I am using tortoisegit, but will use the command line to fix this if need be (I might need my hand held a little for that).

The log looks like this:

*   0.11
|
| * master origin/HEAD origin/master 0.10
| |
|-
|
*   0.9.1

I'm pretty sure after doing the changes for 0.10, that I didn't switch the branch back to 0.9.1 and work on 0.11, but that it was it looks like.

What I want to do is remove 0.11, switch to 0.10, make the changes for 0.11 that I need, then push to github. The changes are small, but I could merge the two, I suppose.

After the changes, the log looks like this:

* (this has no label/branch name)
|
* master origin/HEAD origin/master 0.10
|
* 0.9

Why didn't master get switched to my new changes?

When I do this and try pushing to github, or make any changes and push, I get the error:

git.exe push    "origin" (no branch)

error: src refspec (no does not match any.
error: src refspec branch) does not match any.
error: failed to push some refs to '[email protected]:JoshClose/CsvHelper.git'

I've tried the pull them push method of fixing this issue, but that didn't work. Pulling says that everything is up to date. I've tried doing a --force also, but get the same error.

I think there is a problem with master not being set with my new changes. When I go to push to github, the branch I'm on says (no branch).

What can I do to fix this? I'm ready to just delete the repository and start over.

+1  A: 

You must have checked out directly a tag or a SHA1 commit, making in the process a detached HEAD.
All your updates/modifications took place in this unnamed branch reference by said "detached HEAD".

Before pushing, you should create (declare) a branch, or merging master with HEAD (fast forward) merge.

git branch tmp
git checkout master 
git merge tmp # fast-forward master

That should give you:

* (master,tmp)
|
* origin/HEAD (origin/master) 0.10
|
* 0.9
VonC
What I think happened is, in tortoisegit when you checkout a line that has several branches/tags i.e. `master origin/HEAD origin/master 0.10` it checks out the tag. I explicitly checked out master instead, and then my changes didn't happen in a detached head. I was able to fix my local repo with your suggestions, but then couldn't push still, so I did a force and it worked this time.
Josh Close