About #git

Make your git commit verbose

#git / Jul 24, 2016 / 1 min
Even if committing changes with git is straightforward, sometimes you want to verify all changes before doing it (e.g. to come up with with a nice and meaningfull commit message). Luckily there is --verbose switch for git commit. According to the manual (git commit --help): -v, --verbose Show unified diff between the HEAD commit and what would be committed at the bottom of the commit message template to help the user describe the commit by reminding what changes the commit has.
Read the article

Checkout specific Git branch or tag using its name only

#git / Jan 19, 2016 / 1 min
For some compatibility reasons I needed to checkout specific branch or tag in the Git repository using only it’s name (last part without refs/.../ prefix) from a bash script. For Mercurial repositories it’s not a problem at all thanks to: hg checkout $tagOrBranch I haven’t found similar solution using git checkout, so as a workaround I’ve prepared the following bash script to do the job: git fetch --all if git show-ref | grep "refs/remotes/origin/$tagOrBranch" then echo "It looks like a branch" git checkout -b $tagOrBranch git pull origin $tagOrBranch else if git show-ref --tags | grep "refs/tags/$tagOrBranch\$" then echo "It looks like a tag" git checkout tags/$branchOrTag else echo "No branch / tag '$branchOrTag' found" exit 1 fi fi
Read the article