Pushing to a Remote
The Push command uploads commits from a local branch to a specified remote repository. Especially when you want to share your work with others, pushing your local changes to a remote repository is a necessary step.
Before pushing a branch to a remote repository it's best to make sure your local branch is up-to-date by pulling changes from the remote.
You can decide for yourself which branches you want to push to a remote: by default, every local branch is private to you until you explicitly push it to a remote server.
In most cases, you'll simply want to push your current HEAD branch to a remote server. The easiest way to do this is to simply click thebutton in the toolbar and select the remote branch that shall receive the changes.
Push any Local Branch
In case you need more options or want to push a branch other than HEAD, Tower offers you other ways to push:
- drag the local branch in the sidebar that you want to push and drop it onto the receiving remote branch
- right-click the local branch in the sidebar that you want to push and select
In Git, a local branch can "track" a remote one. Such a relationship helps make a lot of things easier: it provides a default for pushing & pulling and it allows Tower to inform you about unpushed and unpulled commits in the sidebar.
Learn more about "tracking connections" in this documentation.
If the remote branch cannot be fast-forwarded, the push will result in an error. This can happen when another developer pushed new commits to the remote while you were working on a feature. Tower offers the Force Push option in its Push dialog for these situations. Please use this option with extreme care: force pushing will overwrite any new changes on the remote.
Force Pushing is destructive
Using force push is strongly discouraged and considered destructive: using force pushing, you can easily overwrite other developer's work and those changes will be lost. This option is only to be used in very specific use cases. A safer alternative is to use force push with lease, described below.
Force Push with Lease
This feature is a safer version of the force push functionality. It will not overwrite any work on the remote branch if more commits were added to the remote branch (by another colleague or team member). Force push with lease is a fail-safe alternative to force pushing and therefore can be used as the default action any time a force push is needed.
Force push with lease can be accessed via:
- the branch context menu
- the "Repository" menu
- the keyboard shortcut CTRL + ⌘ + U.