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 rename a local Git branch?
- What does cherry-picking a commit with Git mean?
- How do I undo the most recent local commits in Git?
- Undo a Git merge that hasn’t been pushed yet
- fatal: Not a git repository (or any of the parent directories): .git [duplicate]
- Git pushing to remote branch
- How do I undo ‘git add’ before commit?
- How can I see the differences between two branches?
- Need to reset git branch to origin version
- What does “Changes not staged for commit” mean
- How can I merge multiple commits onto another branch as a single squashed commit?
- Why does git say “Pull is not possible because you have unmerged files”?
- Pushing empty commits to remote
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- Stash only one file out of multiple files that have changed with Git?
- What is git fast-forwarding? [duplicate]
- fatal: The current branch master has no upstream branch
- Another git process seems to be running in this repository
- How to cherry-pick multiple commits
- Reset local repository branch to be just like remote repository HEAD
- What is “origin” in Git?
- Another git process seems to be running in this repository
- How do you stash an untracked file?
- How do I call git diff on the same file between 2 different local branches?
- How to git rebase a branch with the onto command?
- Remove a git commit which has not been pushed
- How can I make Git “forget” about a file that was tracked, but is now in .gitignore?
- How to remove files from git staging area?
- How to rename a directory/folder on GitHub website?
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- Create a git patch from the uncommitted changes in the current working directory
- How to undo git reset –soft to get my changes back?
- git push says “everything up-to-date” even though I have local changes
- .gitignore and “The following untracked working tree files would be overwritten by checkout”
- Why does git say “Pull is not possible because you have unmerged files”?
- How to see the changes between two commits without commits in-between?
- Git: Installing Git in PATH with GitHub client for Windows
- How to delete a stash created with git stash create?
- Git: How to update/checkout a single file from remote origin master?
- How to add multiple files to Git at the same time
- ERROR: Error cloning remote repo ‘origin’
- How can I remove a commit on GitHub?
- What is the difference between ‘git remote update’, ‘git fetch’ and ‘git pull’?
- GitLab remote: HTTP Basic: Access denied and fatal Authentication
- Git Extensions: Win32 error 487: Couldn’t reserve space for cygwin’s heap, Win32 error 0
- Delete branches in Bitbucket
- What to gitignore from the .idea folder?git intellij-idea gitignore webstorm
- Is it possible to pull just one file in Git?
- Git lfs – “this exceeds GitHub’s file size limit of 100.00 MB”
- How do you clone a Git repository into a specific folder?
- git checkout master error: the following untracked working tree files would be overwritten by checkout
- How can I see the changes in a Git commit?
- How to discard local changes and pull latest from GitHub repository
- Git removing upstream from local repository
- Git: What’s the best practice to “git clone” into an existing folder?
- Git pull – Please move or remove them before you can merge
- Unlink of file Failed. Should I try again?
- Resetting remote to a certain commit
- Change the location of the ~ directory in a Windows install of Git Bash
- Differences between Commit, Commit and Push, Commit and Sync
- How can I delete all Git branches which have been merged?
- git replace local version with remote version
- Git checkout – switching back to HEAD
- How to create a new branch from a tag?
- Git Workflow for Large, Live Site?
- Workflow for working with git and WordPress
- Git beginner: Keeping track of on-server changes
- best practice on pushing staging development (database/uploads) to the live server
- how can I create a WP offline environment before releasing the websites? [closed]