Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull - default remote and branch using -u option - works with push but not pull

Tags:

git

github

I am on Git version 2.6.3, and get this message when just running

git pull

"There is no tracking information for the current branch."

I was under the impression that git would default to origin and the branch with the same name under the "simple" config.

After some trouble, I discover that the easiest way to configure this is to use the -u option like so:

$ git push -u origin master

then it will say:

"Branch master set up to track remote branch master from origin."

so my question is, why can't we use the -u option with git pull?

$ git pull -u origin master

the -u option is not recognized on pull, only with push

my question is - is there a good reason for that?

like image 215
Alexander Mills Avatar asked Dec 09 '15 19:12

Alexander Mills


People also ask

Does git pull pull all remote branches?

git fetch --all and git pull -all will only track the remote branches and track local branches that track remote branches respectively. Run this command only if there are remote branches on the server which are untracked by your local branches. Thus, you can fetch all git branches.

Does git pull pull from remote?

The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.

Can git fetch but not push?

Some common reasons include: - You are not logged in to your account: see File > Options. - You may need to log out and log back in to refresh your token. - You do not have permission to access this repository. - The repository is archived on GitHub.

Why does git not pull?

Avoid using git pull , unless you're the sole owner and user of the repository. A git pull works by doing a git fetch followed by a git merge . This is OK if your local branch is in sync with the remote branch.


1 Answers

You can use this command to set the upstream of your current branch $ git branch --set-upstream-to=origin/master

This way your setting the upstream branch to master by default when pulling and pushing without actually using a push or pull command.

Now try to git pull and it should start gathering everything from your repository and after that it will say it's Already up-to-date

If you have any further questions, I'll be happy to assist.

like image 138
ALXvirtual Avatar answered Oct 08 '22 23:10

ALXvirtual