How to update local repo with master?

  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.


It is normal for git to open an editor when you pull. This is because you are merging in the changes from the remote to your local branch.

When you pull, git detects whether it needs to merge your local branch with the remote branch. If it needs to merge, it will do so and present you with the opportunity to write a custom message for the merge commit. At that point, you can choose to just close the editor, and git will finish the process.

Basically, all you had to do is close the editor and you would have been done.

Essentially, git is doing the following:

#Download all the commits from the remote
git fetch origin

# Merge in the commits from the remote to your local branch
# If anything needs merging, this will open a text editor
git merge origin/master master

Tags:

Svn

Git

Github