Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update local repo with master?

Tags:

git

github

svn

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

like image 207
user3898238 Avatar asked Nov 18 '14 01:11

user3898238


People also ask

How do I change my repository to master?

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 .

How do I push changes from local repo to remote?

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.


1 Answers

  1. Check your current branch with the command:

    git branch

    It will show your current branch name with an asterisk (*) next the name.

  2. Then update your local branch with the remote branch:

    git pull origin branchname (This is the branch name with asterisks)

  3. 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.

like image 79
Breen ho Avatar answered Sep 22 '22 13:09

Breen ho