Push
suggest changegit push
pushes to the upstream that is already configured. With the Git 2.x default (push.default simple), that is the current branch when it tracks a remote branch of the same name. Git 1.x defaulted to matching, which pushes every local branch that has a remote branch of the same name.
Specify remote repository
When working with git, it can be handy to have multiple remote repositories. To specify a remote repository to push to, just append its name to the command.
git push origin
Specify Branch
To push to a specific branch, say feature_x:
git push origin feature_x
Set the remote tracking branch
git push with no arguments fails the first time a branch has no upstream. If the current branch is master, this pushes it to origin and records that upstream:
git push --set-upstream origin master
master here is the local branch name; the remote branch is given the same name. Use your branch’s name if it is not master. -u is short for --set-upstream.
Pushing to a new repository
To push to a repository that you haven’t made yet, or is empty:
- Create the repository on GitHub (if applicable).
- Copy the URL, in the form
https://github.com/USERNAME/REPO_NAME.git. - In your local repository, run
git remote add origin URL. - Check it with
git remote -v. - Run
git push origin master.
Your commits should now be on GitHub.
Explanation
A push sends commits the remote does not yet have and updates the remote branch. After it succeeds, that remote branch matches the commits you pushed, and other users can fetch them.