| Start | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
Push a specific object to a remote branch General syntaxExampleWill push your master branch to the Delete remote branchDeleting the remote branch is the equivalent of pushing an empty object to it. ExampleWill delete the remote branch Instead of using the colon, you can also use the --delete flag, which is better readable in some cases. ExamplePush a single commitIf you have a single commit in your branch that you want to push to a remote without pushing anything else, you can use the following ExampleAssuming a git history like this to push only commit 347d700 to remote master use the following command |
||||||||||
Push will push your code to your existing upstream. Depending on the push configuration, it will either push code from you current branch (default in Git 2.x) or from all branches (default in Git 1.x). Specify remote repositoryWhen 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. Specify BranchTo push to a specific branch, say Set the remote tracking branchUnless the branch you are working on originally comes from a remote repository, simply using Here, Pushing to a new repositoryTo push to a repository that you haven't made yet, or is empty:
Your code should now be on GitHub For more information view Adding a remote repository (opens new window) ExplanationPush code means that git will analyze the differences of your local commits and remote and send them to be written on the upstream. When push succeeds, your local repository and remote repository are synchronized and other users can see your commits. For more details on the concepts of "upstream" and "downstream", see Remarks. |
||||||||||
| Force Pushing Sometimes, when you have local changes incompatible with remote changes (ie, when you cannot fast-forward the remote branch, or the remote branch is not a direct ancestor of your local branch), the only way to push your changes is a force push. or Important notesThis will overwrite any remote changes and your remote will match your local. Attention: Using this command may cause the remote repository to lose commits. Moreover, it is strongly advised against doing a force push if you are sharing this remote repository with others, since their history will retain every overwritten commit, thus rending their work out of sync with the remote repository. As a rule of thumb, only force push when:
|
||||||||||
Push tags Pushes all of the |
||||||||||
| Changing the default push behavior Current updates the branch on the remote repository that shares a name with the current working branch. Simple pushes to the upstream branch, but will not work if the upstream branch is called something else. Upstream pushes to the upstream branch, no matter what it is called. Matching pushes all branches that match on the local and the remote git config push.default upstream After you've set the preferred style, use to update the remote repository. Syntax
Parameters
RemarksUpstream & DownstreamIn terms of source control, you're **"downstream"** when you copy (clone, checkout, etc) from a repository. Information flowed "downstream" to you. When you make changes, you usually want to send them back **"upstream"** so they make it into that repository so that everyone pulling from the same source is working with all the same changes. This is mostly a social issue of how everyone can coordinate their work rather than a technical requirement of source control. You want to get your changes into the main project so you're not tracking divergent lines of development. Sometimes you'll read about package or release managers (the people, not the tool) talking about submitting changes to "upstream". That usually means they had to adjust the original sources so they could create a package for their system. They don't want to keep making those changes, so if they send them "upstream" to the original source, they shouldn't have to deal with the same issue in the next release. |
Read Article
https://develop.horje.com/learn/1434/reference