Peter Chao
Peter Chao

Reputation: 443

Git command for checkout new master and update master

I am not very clear about some of the git command, and here they are:

  1. To checkout my newly created branch: "my_branch" git pull origin master git checkout my_branch
  2. To update my branch daily: git pull

are my command correct? Thanks for helping.

Upvotes: 0

Views: 1608

Answers (1)

Code-Apprentice
Code-Apprentice

Reputation: 83537

To checkout my newly created branch: "my_branch" git pull origin master git checkout my_branch

These two commands do two different things. git pull origin master pulls the master branch from the origin remote into your current branch. git checkout my_branch checks out a branch named my_branch. If you are only trying to checkout a branch that already exists then git checkout my_branch is enough. You don't need to do git pull origin master in this case.

To update my branch daily: git pull

This will pull the remote tracking branch to your currently checkout out branch. By this I mean that the following two things are the same:

git checkout my_branch
git pull

and

git checkout my_branch
git pull origin my_branch

are my command correct?

That depends on what you want to do. Your question doesn't clearly state your goals for each command. Hopefully the explanations above clarify what these commands do so that you can decide if they are correct for your situation. If not, please edit your question to explain what you want to accomplish.

Upvotes: 1

Related Questions