I am used to using SVN and only recently switched to GitHub.
I am trying to update some files in a GitHub repo, but I get this message:
To https://github.com/.../
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/.../'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
I have tried commands like git fetch origin
and git pull
, but none of these make it so my current branch is not behind.
In SVN I'd just do svn update
and then commit my changes.
I've also tried git pull origin
, but I get a strange text message popping up and I have no idea how to interface with it: Updating a local repository with changes from a Github repository
If you go to the main repo page on GitHub and select the branches dropdown menu, you will see two branches listed and a checkmark next to master .
To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.
Check your current branch with the command:
git branch
It will show your current branch name with an asterisk (*) next the name.
Then update your local branch with the remote branch:
git pull origin branchname (This is the branch name with asterisks)
Now you can push your code to the remote repository if you have already committed your local changes with the command:
git push origin branchname
If you haven't committed yet, first do a commit and then do a git pull and push.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With