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
- How do I check out a remote Git branch?
- How do I use ‘git reset –hard HEAD’ to revert to a previous commit? [duplicate]
- What is git tag, How to create tags & How to checkout git remote tag(s)
- How do I rename a local Git branch?
- Difference between “git add -A” and “git add .”
- Git: Message ‘src refspec master does not match any’ when pushing commits in Git
- Git: Message ‘src refspec master does not match any’ when pushing commits in Git
- What does cherry-picking a commit with Git mean?
- How to cherry pick from 1 branch to another
- How to Git stash pop specific stash in 1.8.3?
- How to use Git Revert
- How do I undo the most recent local commits in Git?
- How do I revert a Git repository to a previous commit?
- What is the best (and safest) way to merge a Git branch into master?
- How to merge branch to master?
- How do I force git pull to overwrite everything on every pull?
- What happens when I do git pull origin master in the develop branch?
- Undo a Git merge that hasn’t been pushed yet
- fatal: Not a git repository (or any of the parent directories): .git [duplicate]
- How can I switch to another branch in git?
- How to remove local (untracked) files from the current Git working tree
- Squash my last X commits together using Git
- Git merge hotfix branch into feature branch
- Git refusing to merge unrelated histories on rebase
- Git submodule update
- How to apply a patch generated with git format-patch?
- What is the `git restore` command and what is the difference between `git restore` and `git reset`?
- What does ‘git merge –abort is equivalent to git reset –merge when MERGE_HEAD is present.’ of Git merge man page mean?
- What does ‘git blame’ do?
- Abort a Git Merge
- Git fetch remote branch
- How to delete a remote tag?
- Updates were rejected because the tip of your current branch is behind its remote counterpart
- Updates were rejected because the tip of your current branch is behind its remote counterpart
- git stash apply version
- How to modify existing, unpushed commit messages?
- How do I clone a specific Git branch? [duplicate]
- Git pushing to remote branch
- How to revert a merge commit that’s already pushed to remote branch?
- What is Git pruning?
- Git pushing to remote branch
- git – remote add origin vs remote set-url origin
- How do I undo ‘git add’ before commit?
- Git: Message ‘src refspec master does not match any’ when pushing commits in Git
- GitHub Error Message – Permission denied (publickey)
- Git fetch remote branch
- How can I see the differences between two branches?
- How to upgrade Git on Windows to the latest version
- Reset local repository branch to be just like remote repository HEAD
- Practical uses of git reset –soft?
- Need to reset git branch to origin version
- Updating a local repository with changes from a GitHub repository
- How do I remove a submodule?
- LF will be replaced by CRLF in git – What is that and is it important? [duplicate]
- git: fatal: Could not read from remote repository
- Git push results in “Authentication Failed”
- What does “Changes not staged for commit” mean
- github changes not staged for commit
- Git : fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists
- Windows git “warning: LF will be replaced by CRLF”, is that warning tail backward?
- git: fatal: Could not read from remote repository
- Git push results in “Authentication Failed”
- What does “Changes not staged for commit” mean
- Download single files from GitHub
- Git error: “Please make sure you have the correct access rights and the repository exists”
- How do I update Homebrew?
- Git error when trying to push — pre-receive hook declined
- Undoing a git rebase
- How do I pull my project from github?