Home > Software engineering >  Git won't push recent commits to github
Git won't push recent commits to github

Time:12-04

I have got a local repository with about 60 commits. At about the 20th commit I pushed the project to a github repository.

My local commit history line (git log --oneline):

5cbd92c (HEAD -> master) Aflevering 70
fafeabb Aflevering 69
3ead1e4 Aflevering 67
37cb1b3 Aflevering 47
a8aab19 Aflevering 46
1cc0b4b Aflevering 44
4301621 Aflevering 43
353a626 Aflevering 34
2f42859 Aflevering 32
0027fc5 Aflevering 29
21eadaa Aflevering 28
be4226a (origin/master, master) Aflevering 20
6b6c5fe Aflevering 16
41c4426 Aflevering 12
0737348 Aflevering 10

I would expect that with

git push origin master

my whole master branch would be pushed to github. But instead the response is

Everything up to date

and nothing is uploaded to github.

What am I doing wrong?

Kind regards,

Hubert

Edit: here's what git for-each-ref dumps out after some poking around, with od -bc to expose any bad characters:

bash$ git for-each-ref | od -bc
0000000 065 143 142 144 071 062 143 143 144 070 143 071 141 067 070 143
         5   c   b   d   9   2   c   c   d   8   c   9   a   7   8   c
0000020 061 146 143 060 146 070 061 062 067 070 141 066 070 063 063 145
         1   f   c   0   f   8   1   2   7   8   a   6   8   3   3   e
0000040 060 143 063 060 067 067 144 067 040 143 157 155 155 151 164 011
         0   c   3   0   7   7   d   7       c   o   m   m   i   t   \t
0000060 162 145 146 163 057 150 145 141 144 163 057 142 141 143 153 165
         r   e   f   s   /   h   e   a   d   s   /   b   a   c   k   u
0000100 160 012 142 145 064 062 062 066 141 063 062 064 071 066 064 144
         p   \n  b   e   4   2   2   6   a   3   2   4   9   6   4   d
0000120 146 141 146 063 062 071 071 067 065 063 145 141 144 061 070 145
         f   a   f   3   2   9   9   7   5   3   e   a   d   1   8   e
0000140 060 061 062 064 063 065 143 061 067 143 040 143 157 155 155 151
         0   1   2   4   3   5   c   1   7   c       c   o   m   m   i
0000160 164 011 162 145 146 163 057 150 145 141 144 163 057 155 141 163
         t   \t  r   e   f   s   /   h   e   a   d   s   /   m   a   s
0000200 164 145 162 012 065 143 142 144 071 062 143 143 144 070 143 071
         t   e   r   \n  5   c   b   d   9   2   c   c   d   8   c   9
0000220 141 067 070 143 061 146 143 060 146 070 061 062 067 070 141 066
         a   7   8   c   1   f   c   0   f   8   1   2   7   8   a   6
0000240 070 063 063 145 060 143 063 060 067 067 144 067 040 143 157 155
         8   3   3   e   0   c   3   0   7   7   d   7       c   o   m
0000260 155 151 164 011 162 145 146 163 057 150 145 141 144 163 057 164
         m   i   t   \t  r   e   f   s   /   h   e   a   d   s   /   t
0000300 145 163 164 012 142 145 064 062 062 066 141 063 062 064 071 066
         e   s   t   \n  b   e   4   2   2   6   a   3   2   4   9   6
0000320 064 144 146 141 146 063 062 071 071 067 065 063 145 141 144 061
         4   d   f   a   f   3   2   9   9   7   5   3   e   a   d   1
0000340 070 145 060 061 062 064 063 065 143 061 067 143 040 143 157 155
         8   e   0   1   2   4   3   5   c   1   7   c       c   o   m
0000360 155 151 164 011 162 145 146 163 057 162 145 155 157 164 145 163
         m   i   t   \t  r   e   f   s   /   r   e   m   o   t   e   s
0000400 057 157 162 151 147 151 156 057 155 141 163 164 145 162 012 065
         /   o   r   i   g   i   n   /   m   a   s   t   e   r   \n  5
0000420 143 142 144 071 062 143 143 144 070 143 071 141 067 070 143 061
         c   b   d   9   2   c   c   d   8   c   9   a   7   8   c   1
0000440 146 143 060 146 070 061 062 067 070 141 066 070 063 063 145 060
         f   c   0   f   8   1   2   7   8   a   6   8   3   3   e   0
0000460 143 063 060 067 067 144 067 040 143 157 155 155 151 164 011 162
         c   3   0   7   7   d   7       c   o   m   m   i   t   \t  r
0000500 145 146 163 057 162 145 155 157 164 145 163 057 157 162 151 147
         e   f   s   /   r   e   m   o   t   e   s   /   o   r   i   g
0000520 151 156 057 164 145 163 164 012 142 145 064 062 062 066 141 063
         i   n   /   t   e   s   t   \n  b   e   4   2   2   6   a   3
0000540 062 064 071 066 064 144 146 141 146 063 062 071 071 067 065 063
         2   4   9   6   4   d   f   a   f   3   2   9   9   7   5   3
0000560 145 141 144 061 070 145 060 061 062 064 063 065 143 061 067 143
         e   a   d   1   8   e   0   1   2   4   3   5   c   1   7   c
0000600 040 143 157 155 155 151 164 011 162 145 146 163 057 162 145 155
             c   o   m   m   i   t   \t  r   e   f   s   /   r   e   m
0000620 157 164 145 163 057 157 162 151 147 151 156 062 057 155 141 163
         o   t   e   s   /   o   r   i   g   i   n   2   /   m   a   s
0000640 164 145 162 012
         t   e   r   \n
0000644

CodePudding user response:

Edit, per (my) question edit based on conversation ... this is most peculiar and you seem to have hit a bug in Git, as git for-each-ref shows only one master branch, despite your git log output, which shows two master branches.

The actual branch name holds be4226a..., which explains the git push result. But nothing explains the HEAD -> master at 5cbd92c.... You do have two branch names now (backup and test) that remember this commit. Depending on where and how the bug is manifesting, the following sequence may work to fix the problem:

$ git checkout backup
$ git branch -d master
$ git branch master
$ git checkout master
$ git branch --set-upstream-to origin/master

At this point, git log --oneline should show HEAD -> master on commit 5cbd92c and git push origin master should work.

[Original answer below.]


Your output shows two branches named master:

5cbd92c (HEAD -> master) Aflevering 70

and:

be4226a (origin/master, master) Aflevering 20

Now, it's not possible to have two branches with the same name,1 so one of these must actually be some other name that simply looks like master. For git push to behave the way it does, the one named master must be the second one, that's even with origin/master; the current branch, as indicated by HEAD -> master at commit 5cbd92c, must be the one whose name looks like master but isn't actually master (perhaps it's mas<invisible-character>ter or something along those lines: if you're on a Linux system, use git branch | cat -v or git for-each-ref refs/heads | od -bc or similar).


1Unless you've somehow found a bug in Git, which is rare but not unheard-of.

  • Related