Git push won't do anything (everything up-to-date)

后端 未结 16 2195
轻奢々
轻奢々 2020-12-04 05:38

I\'m trying to update a Git repository on GitHub. I made a bunch of changes, added them, committed then attempted to do a git push. The response tells me that e

相关标签:
16条回答
  • 2020-12-04 06:06

    Try git add -A instead of git add .

    0 讨论(0)
  • 2020-12-04 06:10
    git push origin master
    
    0 讨论(0)
  • 2020-12-04 06:13

    Right now, it appears as you are on the develop branch. Do you have a develop branch on your origin? If not, try git push origin develop. git push will work once it knows about a develop branch on your origin.

    As further reading, I'd have a look at the git-push man pages, in particular, the examples section.

    0 讨论(0)
  • 2020-12-04 06:13

    This happened to me once I tried to push from a new branch and I used git push origin master instead. You should either:

    • Use: git push origin your_new_branch if you want that this branch occurs too in the remote repo.
    • Else check out to your master branch merge things then push to from master to git repo with git merge origin master.

    Recap: the point here is that you should check out where you offer on the second parameter for git merge. So if you are in the master use master as the second parameter if you are in the new_branch use this as the second parameter if you want to keep this branch in the remote repo else opt for the second option above instead.

    0 讨论(0)
  • 2020-12-04 06:14

    git push doesn't push all of your local branches: how would it know which remote branches to push them to? It only pushes local branches which have been configured to push to a particular remote branch.

    On my version of Git (1.6.5.3), when I run git remote show origin it actually prints out which branches are configured for push:

    Local refs configured for 'git push':
      master pushes to master (up to date)
      quux   pushes to quux   (fast forwardable)
    

    Q. But I could push to master without worrying about all this!

    When you git clone, by default it sets up your local master branch to push to the remote's master branch (locally referred to as origin/master), so if you only commit on master, then a simple git push will always push your changes back.

    However, from the output snippet you posted, you're on a branch called develop, which I'm guessing hasn't been set up to push to anything. So git push without arguments won't push commits on that branch.

    When it says "Everything up-to-date", it means "all the branches you've told me how to push are up to date".

    Q. So how can I push my commits?

    If what you want to do is put your changes from develop into origin/master, then you should probably merge them into your local master then push that:

    git checkout master
    git merge develop
    git push             # will push 'master'
    

    If what you want is to create a develop branch on the remote, separate from master, then supply arguments to git push:

    git push origin develop
    

    That will: create a new branch on the remote called develop; and bring that branch up to date with your local develop branch; and set develop to push to origin/develop so that in future, git push without arguments will push develop automatically.

    If you want to push your local develop to a remote branch called something other than develop, then you can say:

    git push origin develop:something-else
    

    However, that form won't set up develop to always push to origin/something-else in future; it's a one-shot operation.

    0 讨论(0)
  • 2020-12-04 06:14

    Please try going to the last commit and then do git push origin HEAD:master.

    0 讨论(0)
提交回复
热议问题