1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 08:08:02 +00:00

Add Push To A Branch On Another Remote as a git til

This commit is contained in:
jbranchaud
2021-05-14 16:38:31 -05:00
parent a77bb62429
commit 7082775f0e
2 changed files with 38 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
_1123 TILs and counting..._ _1124 TILs and counting..._
--- ---
@@ -268,6 +268,7 @@ _1123 TILs and counting..._
- [Move The Latest Commit To A New Branch](git/move-the-latest-commit-to-a-new-branch.md) - [Move The Latest Commit To A New Branch](git/move-the-latest-commit-to-a-new-branch.md)
- [Pick Specific Changes To Stash](git/pick-specific-changes-to-stash.md) - [Pick Specific Changes To Stash](git/pick-specific-changes-to-stash.md)
- [Pulling In Changes During An Interactive Rebase](git/pulling-in-changes-during-an-interactive-rebase.md) - [Pulling In Changes During An Interactive Rebase](git/pulling-in-changes-during-an-interactive-rebase.md)
- [Push To A Branch On Another Remote](git/push-to-a-branch-on-another-remote.md)
- [Quicker Commit Fixes With The Fixup Flag](git/quicker-commit-fixes-with-the-fixup-flag.md) - [Quicker Commit Fixes With The Fixup Flag](git/quicker-commit-fixes-with-the-fixup-flag.md)
- [Rebase Commits With An Arbitrary Command](git/rebase-commits-with-an-arbitrary-command.md) - [Rebase Commits With An Arbitrary Command](git/rebase-commits-with-an-arbitrary-command.md)
- [Reference A Commit Via Commit Message Pattern Matching](git/reference-a-commit-via-commit-message-pattern-matching.md) - [Reference A Commit Via Commit Message Pattern Matching](git/reference-a-commit-via-commit-message-pattern-matching.md)

View File

@@ -0,0 +1,36 @@
# Push To A Branch On Another Remote
The kind of `git-push` I do most often is:
```bash
$ git push origin HEAD
```
which I have aliased to `put` in my `.gitconfig`.
`HEAD` generally refers to whatever branch you currently have checked out. So
this command will take the state of your current branch and push it to the
branch of the same name on the `origin`, which is a _remote_ (see `git remote
-v`).
If you have other remotes set up, such as a `staging`, `heroku`, etc., then you
may instead want to push to one of those.
```bash
$ git push heroku HEAD
```
This will push the state of the current branch to that branch on the `heroku`
remote.
If I instead want to push the changes from one local branch to a different
named remote branch, then I have to specify both like so:
```bash
$ git push heroku staging:main
```
This will push the state of my local `staging` branch to the `main` branch on
the `heroku` remote.
[source](https://devconnected.com/how-to-push-git-branch-to-remote/)