πŸ“œ ⬆️ ⬇️

Git up and everything is all

The git up command (similar to svn up) is added as follows:
git config --global alias.up '!(git add . && git stash && git pull --rebase >&2) | grep -v "No local changes to save" && git stash pop' 

git up, if necessary, stumbles into the still uncommitted changes in the stash, updates the local branch to the latest and restores the local changes back. It also transfers still unsent local commits to the very end, making the history linear as in Subversion, i.e. avoiding unnecessary branches and merge commits.

If everything went smoothly (without conflicts), you can immediately do git push. In rare cases of conflict (you and someone changed the same line), the rebase stops and then, of course, you have to figure it out yourself and complete the update with git rebase - continue how many times you need and use git stash to return the stitched changes.

There are many analogues, but for the most part these are non-conforming scripts. Alias ​​is easy to add on any server along with others simply by inserting all this into the console:

 # git up git config --global alias.up '!(git add . && git stash && git pull --rebase >&2) | grep -v "No local changes to save" && git stash pop' # git in / git out β€”    /   pull/push git config --global alias.in '!git remote update -p; git log ..@{u}' git config --global alias.out 'log @{u}..' # git addremove -     /      git config --global alias.addremove \!"git add . && git ls-files --deleted | xargs --no-run-if-empty git rm" # git unstage -     (  /  - ) git config --global alias.unstage "reset HEAD --" # git backup -       git config --global alias.backup \!'file=../`git describe`.tar && echo "Creating `readlink -f $file`" && tar cf $file .' #    git config --global alias.st "status -sb" git config --global alias.ci commit git config --global alias.co checkout git config --global alias.br branch git config --global alias.bra "branch -a" git config --global alias.chp cherry-pick git config --global alias.pr "pull --rebase" git config --global alias.bl "blame -b -w" git config --global alias.cia "commit --amend" git config --global alias.lg "log --pretty=format:'%h was %an, %ar, message: %s' --graph" git config --global alias.who "shortlog -s --" # what else? 

Share useful aliases!

')

Source: https://habr.com/ru/post/155391/


All Articles