sushantmane / git-tricks

Git Tips and Tricks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Git: Tips and Tricks

Enable auto-completion and display current branch

 curl -kL https://raw.githubusercontent.com/sushantmane/git-tricks/master/git-setup.sh | bash && . ~/.bashrc

Enable only Auto-Completion

This allows auto-completion of git commands in terminal

 curl -kL https://raw.githubusercontent.com/sushantmane/git-tricks/master/git-autocompletion.sh | bash && . ~/.bashrc

Display only current branch in terminal prompt

To display name of current branch in terminal prompt like this

 [root (master) git-tricks]$
 curl -kL https://raw.githubusercontent.com/sushantmane/git-tricks/master/git-show-branch.sh | bash && . ~/.bashrc

Create and apply patch with git

Create patch from

latest commit

 git format-patch HEAD^ --stdout > bug_id.patch

or

a specific commit

 git format-patch -1 <SHA1> --stdout > bug_id.patch

or

a specific sha1 hash to the topmost commits

 git format-patch -<n> <SHA1> --stdout > bug_id.patch

Applying the patch

To take a look at what changes are in the patch.

 git apply --stat bug_id.patch

To check if this patch can be aplied cleanly.

 git apply --check bug_id.patch

Now applay a patch

git apply < bug_id.patch

or

applay patch with sign off

 git am --signoff < bug_id.patch

About

Git Tips and Tricks


Languages

Language:Shell 100.0%