Last active
May 6, 2020 16:38
-
-
Save salewski/9eea0b242538b96bb588bae47f60d485 to your computer and use it in GitHub Desktop.
Provides two new git aliases: 'ads-push-all-from-upstream' and 'ads-push-all-from-upstream-force'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- conf-unix -*- | |
# snippet for your ~/.gitconfig file | |
# provides two new git aliases: | |
# * ads-push-all-from-upstream | |
# * ads-push-all-from-upstream-force | |
# ... | |
[alias] | |
# ... | |
# When you have an "origin" remote (often your own GitHub fork) and also | |
# an "upstream" remote, you may want to ensure all of the branches that | |
# have appeared upstream since the point at which you forked are also | |
# available in your fork. One way to do this is with a mirror repo, which | |
# works fine if don't mind the out-of-band process and the lack of a | |
# working directory (since a "mirror" repos is, by definition, a | |
# specialization of a "bare" repo). However, if you've already got a | |
# non-bare clone (that is, your local repo has a git working directory), | |
# you can achieve the same result by pushing all of the refs from your | |
# "upstream" remote to your "origin" fork. | |
# | |
# CAREFUL: Assumes remotes are named "upstream" and "origin" | |
# | |
# CAREFUL: The *-force variation will resolve any ref namespace collisions | |
# in favor of the ref from upstream. For best results, namespace | |
# your personal branches in such a way as to avoid the | |
# collisions. | |
# | |
# Note that we use a shell command (bang syntax) because we want to | |
# display the full git command that is being invoked. | |
# | |
ads-push-all-from-upstream = !(set -x && git push --follow-tags 'origin' 'refs/remotes/upstream/*:refs/heads/*') | |
ads-push-all-from-upstream-force = !(set -x && git push --follow-tags 'origin' '+refs/remotes/upstream/*:refs/heads/*') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment