I have a local repo that I want to push to github. But it doesn't push, because it thinks that the working tree is clean.
This is the output:
shmuel@nixos ~/nixos master ± git add . && git commit -m config && git push origin master
[master ab79eda] config
1 file changed, 1 insertion(+)
To github.com:shmu26/NIX.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'github.com:shmu26/NIX.git'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
✘ shmuel@nixos ~/nixos master git add . && git commit -m config && git pull origin master
On branch master
nothing to commit, working tree clean
✘ shmuel@nixos ~/nixos master git add . && git commit -m config && git push origin master
On branch master
nothing to commit, working tree clean
I set up the credentials, but when I try to push, it says that first I need to pull. So I pull. Then, when I try again to push, it says the tree is clean. So nothing gets pushed.
error is not on
git pushcommand rather ingit addandgit commitThat's because:
So, after you run
git pullcommand, git is creating a new merge commit (if there is no merge conflicts).As a result your working tree is clean and can't stage nor commit. If you are okay with git created commit, you should just push it to remote
git pull origin master && git push origin masterIf it is not what you want, you can use
git fetchand merge as you like.Or you can use
rebaseoption as outline in this answergit pull --rebase <remote-name> <branch-name>