Created
February 7, 2022 22:50
Revisions
-
miere created this gist
Feb 7, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ # Useful Git Aliases Here are a few aliases that I use on my daily routine. I'm sharing this as it might be helpful for other developers, too. ## The Script ```shell #!/bin/sh # Push configuration will always assume same branch name in the given remote repository # If only one remote location exists, it won't ask it. git config --global push.default current # Important aliases that prevents me to do mistakes git config --global alias.update 'pull --rebase' git config --global alias.publish 'push' git config --global alias.fork 'checkout -b' git config --global alias.amend 'commit --amend' # Saves your current git config --global alias.save 'stash --' git config --global alias.load 'stash pop' # Shortcuts git config --global alias.st 'status -s' git config --global alias.ls 'log --oneline --abbrev-commit' git config --global alias.co 'commit' ``` ## Hands on ### Switching between branches Allows one to switch between branches using a more intuitive syntax. ```shell git switch <my-branch> ``` ### Creating a new branch (forking) from the current one Allows one to create a new branch using a more intuitive syntax. ```shell git fork <new-branch-name> ``` ### Keeping your branch updated with the upstream repository Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows. This particular alias will help you to keep things in sync without introducing merge commits, using a [rebase](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) strategy to solve conflicts. ```shell git update ``` ### Publishing your changes to the upstream repository Transfer commits from your local repository to a remote repo. ```shell git publish ``` ### Temporarily saving your changes Temporarily shelves changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on. ```shell git save ``` ### Loading temporarily saved changes Loads previously shelved changes. ```shell git load ```