Manjunath Manoharan
Manjunath Manoharan

Reputation: 4617

GIT repository pull command

I generally do the git pull command to fetch+merge with my local repositor from remote repo

  1. Does git pull fetches+merges all the branches from github repo or just do the operation specifically for the branch upon which the refs have been defined. ??

  2. Suppose I have not defined the refs for a particular branch and if I call git pull on that, what does it do ?? I have tried to observe it many times but I do not have a complete understanding about it.

  3. I have made a lot of changes to a particular file, now if I git pull on that branch. Will my changes just go away and get merged with the pulled file. ??

Upvotes: 1

Views: 437

Answers (2)

Eugene Sajine
Eugene Sajine

Reputation: 8200

  1. git pull without parameters will work only if the branch you currently checked out is configured for parameterless pull, i.e. it is a tracking branch. You can see branches configured for parameterless pull and push by using git remote show remotename

  2. in this case it will actually print out a text saying that you didn't specify the branch with which you expect git to work

  3. If your changes are committed and not conflicting with whatever you have pulled from remote - they will be merged together. They will not go away. OTOH if you know or think that the the remote branch might have changes that your local branch doesn't have i would recommend to use git pull --rebase. If your changes are not committed the operation will be aborted and you will have to commit those or stash

Upvotes: 1

JJD
JJD

Reputation: 51892

  1. Git does only try to merge the branch at which you run the pull command. Other branches are fetched only.
  2. Git fetch receives the latest information for all branches.
  3. Git will inform you that your working tree is not clean and asks you to either stash the changes or commit them.

Upvotes: 1

Related Questions