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
This happened to me when I ^C
in the middle of a git push
to GitHub. GitHub did not show that the changes had been made, however.
To fix it, I made a change to my working tree, committed, and then pushed again. It worked perfectly fine.
I tried many methods including defined here. What I got is,
Make sure the name of repository is valid. The best way is to copy the link from repository site and paste in git bash.
Make sure you have commited the selected files.
git commit -m "Your commit here"
If both steps don't work, try
git push -u -f origin master
For my case, none of other solutions worked. I had to do a backup of new modified files (shown with git status
), and run a git reset --hard
. This allowed me to realign with the remote server. Adding new modified files, and running
git add .
git commit -am "my comment"
git push
Did the trick. I hope this helps someone, as a "last chance" solution.
To be specific, if you want to merge something to master, you can follow the below steps.
git add --all // If you want to stage all changes other options also available
git commit -m "Your commit message"
git push // By default when it clone is sets your origin to master or you would have set sometime with git push -u origin master.
It's a common practice in the pull request model create to a new local branch and then push that branch to remote. For that you need to mention where you want to push your changes at remote. You can do this by mentioning remote at the time of push.
git push origin develop // It will create a remote branch with name "develop".
If you want to create a branch other than your local branch name you can do that with the following command.
git push origin develop:some-other-name
This happened to me. I just re-committed the changes, and then it pushed.
This happened to me when my SourceTree application crashed during staging. And on the command line, it seemed like the previous git add
had been corrupted. If this is the case, try:
git init
git add -A
git commit -m 'Fix bad repo'
git push
On the last command, you might need to set the branch.
git push --all origin master
Bear in mind that this is enough if you haven't done any branching or any of that sort. In that case, make sure you push to the correct branch like git push origin develop
.