To avoid confusion,
recent versions ofgit
deprecate this somewhat ambiguous--set-upstream
option
in favor of a more verbose--set-upstream-to
option
with identical syntax and behavior.
git branch --set-upstream-to <remote-branch>
sets the default remote branch for the current local branch.
Any future git pull
command (with the current local branch checked-out),
will attempt to bring in commits from the <remote-branch>
into the current local branch.
One way to avoid having to explicitly type --set-upstream
/ --set-upstream-to
is to use its shorthand flag -u
as follows:
git push -u origin local-branch
This sets the upstream association for any future push/pull attempts automatically.
For more details, checkout this detailed explanation about upstream branches and tracking.
Related Posts:
- What does ‘–set-upstream’ do?
- How do I delete a Git branch locally and remotely?
- How do I delete a Git branch locally and remotely?
- error: src refspec master does not match any
- How do I properly force a Git push?
- What is the difference between git push origin and git push origin master
- How do I push a new local branch to a remote Git repository and track it too?
- How do I push a new local branch to a remote Git repository and track it too?
- How do I push a new local branch to a remote Git repository and track it too?
- What are the differences between “git commit” and “git push”?
- GitHub: Permission denied (publickey). fatal: Could not read from remote repository
- How do you push a tag to a remote repository using Git?
- How to change the URI (URL) for a remote Git repository?
- rejected master -> master (non-fast-forward)
- rejected master -> master (non-fast-forward)
- Meaning of the GitHub message: push declined due to email privacy restrictions
- Git Giving “fetch first” error when trying to push
- How to remove remote origin from a Git repository
- git – Your branch is ahead of ‘origin/master’ by 1 commit
- ! [rejected] master -> master (fetch first)
- Set up git to pull and push all branches
- Why does Git tell me “No such remote ‘origin'” when I try to push to origin?
- Undoing a ‘git push’
- What does git push origin HEAD mean?
- What does git push origin HEAD mean?
- How do I push a local Git branch to master branch in the remote?
- git push not send changes to remote git repository
- Git push hangs when pushing to Github?
- How can I push a specific commit to a remote, and not previous commits?
- Git Push Error: insufficient permission for adding an object to repository database
- Git push requires username and password
- Git: Message ‘src refspec master does not match any’ when pushing commits in Git
- How do I force git pull to overwrite everything on every pull?
- Git refusing to merge unrelated histories on rebase
- What does ‘git blame’ do?
- What is Git pruning?
- git – remote add origin vs remote set-url origin
- Git: Message ‘src refspec master does not match any’ when pushing commits in Git
- How to upgrade Git on Windows to the latest version
- Reset local repository branch to be just like remote repository HEAD
- LF will be replaced by CRLF in git – What is that and is it important? [duplicate]
- git: fatal: Could not read from remote repository
- github changes not staged for commit
- Git error: “Please make sure you have the correct access rights and the repository exists”
- How do I pull my project from github?
- Difference between Git and GitHub
- Could not open a connection to your authentication agent
- Hard reset of a single file
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- How do I revert all local changes in Git managed project to previous state?
- How do I revert all local changes in Git managed project to previous state?
- How to revert multiple git commits?
- The following untracked working tree files would be overwritten by merge, but I don’t care
- You have not concluded your merge (MERGE_HEAD exists)
- How to compare files from two different branches
- git – pulling from specific branch
- How to pull a specific branch from Github
- How to fully delete a git repository created with init?
- There is no tracking information for the current branch
- Git push results in “Authentication Failed”
- Git reset single file in feature branch to be the same as in master
- What is difference between ‘git reset –hard HEAD~1’ and ‘git reset –soft HEAD~1’?
- What are the differences between .gitignore and .gitkeep?
- Git – Undo pushed commits
- How to remove the shallow clone warning from HomeBrew
- Files not updating using ‘git pull’
- git checkout tag, git pull fails in branch
- What is the point of ‘git submodule init’?
- How can I copy the content of a branch to a new local branch?
- Git: “please tell me who you are” error
- How to change folder with git bash?
- Git:nothing added to commit but untracked files present
- How to commit changes to another pre-existent branch
- git: How to ignore all present untracked files?
- Move existing, uncommitted work to a new branch in Git
- “git checkout
” is changing branch to “no branch” - Why I always Got Error “Push to origin/master was rejected”?
- How to resolve git status “Unmerged paths:”?
- How do I list all of the files in a commit?
- Git keeps prompting me for a password
- Resolve Git merge conflicts in favor of their changes during a pull
- Git stash pop- needs merge, unable to refresh index
- Push local Git repo to new remote including all branches and tags
- Git – Remove commit from history
- Git merge without auto commit
- How to get Git to clone into current directory
- List submodules in a Git repository
- How can I reconcile detached HEAD with master/origin?
- How do I run git log to see changes only for a specific branch?
- How to search in commit messages using command line?
- Staging Deleted files
- How to get changes from another branch
- gerrit – git (pull vs checkout vs cherrypick) which is for what?
- GIT_DISCOVERY_ACROSS_FILESYSTEM not set
- Difference between git stash pop and git stash apply
- How do I show the changes which have been staged?
- I use SourceTree with Git but need to work with SVN repistory, what options do I have?
- Theme/Plugin/Widget Data and Staging/Production Servers
- How to retrieve the last modification date of all files in a Git repository
- How do I edit git’s history to correct an incorrect email address/name [closed]