Git push doesn't fail but doesn't work

2019-02-25 04:28发布

I'm using Git and I'm in front of a several problem: I can push, my coworkers can pull it, and the opposite. But the version which is on the remote is not up-to-date: if I write a TEST in the html, nobody could see it except on the local version... I thought it could come from the branch which is on the remote... isn't it ?

EDIT 1 : I'll try to be more specific: I've a private repo which is on a private server. This server is used to host the website. When i commit -> pull -> push everything works great. When my coworker do the same, it's fine. On our local version, all the changes appear like my "TEST" test. But on the server, nothing is up to date. Is it the wrong branch, on the server or something?

PS : Sorry for my english, it's not my native language.

标签: git push
3条回答
等我变得足够好
2楼-- · 2019-02-25 05:00

If you are doing a plain 'git push' you may need to do 'git push origin branchname' instead. Provided the file is committed, of course.

UPDATE: Check your .git/config file. You should have an origin specified and your branch should refer to origin. Maybe there is a mismatch.

[remote "origin"]
    url = [your github repo]
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "yourbranch"]
    remote = origin
    merge = refs/heads/yourbranch
查看更多
萌系小妹纸
3楼-- · 2019-02-25 05:06

I had the same problem which looks really similar to what Vautrinr had. I also committed and had the same response to some of the things suggested in the previous answers.

The final solution to my problem comes from this awesome answer. It turns out that my HEAD was detached and all the commits I did didn't go into the master branch. When trying to push to remote server, git failed to find any difference between the two master branches and thus "Everything up to date." After fixing the detached HEAD problem, I was finally able to push my changes.

Hope this help.

查看更多
够拽才男人
4楼-- · 2019-02-25 05:14

The question is quite unclear, but several things can go wrong.

  • You need to git commit changes first. Otherwise your changes are simply not stored (unknown to git).

  • You've committed on a special branch. In that case the commits are actually stored on the server, but not shown by default. Other users can the checkout the branch by performing

    git checkout <branch>
    

    detecting on which branch you are yourself can be done with

    git branch
    
  • You and your workers use different remote servers. You can check this by running

    git remote
    

    to generate a list of installed remotes

  • ...

查看更多
登录 后发表回答