Last active
November 27, 2024 16:38
-
-
Save chrisribe/218e98590ae7be1e294ac9fc3562c9ce to your computer and use it in GitHub Desktop.
Alias 'mainup' for Updating and Keeping 'main' Branch Up-to-Date While on Working Branch
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
# Set up a Git alias called 'mainup' that updates the 'main' branch and brings it up-to-date while staying on the current working branch | |
# Run the following command to set up the alias: | |
git config --global alias.mainup '!git rev-parse --abbrev-ref HEAD > .git/CURRENT_BRANCH && git checkout main && git pull && git checkout $(cat .git/CURRENT_BRANCH) && rm .git/CURRENT_BRANCH' | |
# Now you can update the 'main' branch and bring it up-to-date while staying on your working branch by running the 'mainup' command: | |
git mainup | |
## Same for master | |
git config --global alias.masterup '!git rev-parse --abbrev-ref HEAD > .git/CURRENT_BRANCH && git checkout master && git pull && git checkout $(cat .git/CURRENT_BRANCH) && rm .git/CURRENT_BRANCH' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment