Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why did a git pull origin master not work, but a git pull did?

So I ran into a peculiar problem this morning, and I was wondering if the community could help me figure it out. So I've been doing git pull origin master when I want to fetch and merge the projects changes from the remote master copy and bring them to my local master.

I've been running into some merging issues lately though, so I did an experiment -
I did a git pull origin master like always, and got the message that said "Already up-to-date."

Then I did a normal git pull and then saw all of my coworkers changes rolling in and merging with my local master branch.

Why did a git pull origin master not work, but a git pull did?

I wonder how many changes I haven't been seeing because of this quirk I discovered. I've done some research to find out what the differences are but I still haven't found a reason why my repo wasn't being updated properly with a git pull origin master, when I've seen changes being fetched and merged into my branch with that method before.

Thoughts?

Thanks in advance.

like image 958
user1517898 Avatar asked Jul 11 '12 13:07

user1517898


People also ask

Is git pull and git pull origin master same?

Remember, a pull is a fetch and a merge. git pull origin master fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out.

Why git pull is not working?

This might be happening because of some conflict files present in your repository . And you was still trying to check in files . So After that what happen , it will check in your local repository not in master repository . So u was not able to pull or check in anythings in master(head) repository .

Does git pull affect master?

It only affects your current branch, not your local master branch. Your local master branch is irrelevant in this. git pull is essentially a combination of git fetch and git merge ; it fetches the remote branch then merges it into your current branch. It's a merge like any other; it doesn't do anything magical.

How do I pull a git origin master?

'git pull origin master' will fetch and update only a specific branch called master and origin in the remote repository. Often, the default branch in Git is a master branch, and it keeps updating frequently. A user can use any branch name to pull that branch from the remote.


1 Answers

It sounds like your local branch isn't tracking what you think it is. Try issuing git remote show origin and check the "Local branch configured for 'git pull':" section. git pull without specification will default from the "remote" and "merge" configuration of the current branch, per the man page:

Default values for and are read from the "remote" and "merge" configuration for the current branch as set by git-branch(1) --track.

I'd bet you have a different branch configured for tracking than origin/master. It's also possible you're pulling from a different remote. To verify these possibilities, try:

git config branch.master.remote ;# shows you the tracked remote
git config branch.master.merge ;# shows you the tracked upstream branch

These assume your local branch is called master.

like image 91
Christopher Avatar answered Sep 29 '22 03:09

Christopher