search

Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Wednesday, October 7, 2015

git: How to change the author of the commit

If you want to change the author of the specific commit (for example the latest one), run rebase command:
git rebase -i HEAD~1
HEAD~1 points to the latest commit, but it can be a commit id or branch name. To mark a commit for edit, replace `pick` with `e`: Replace commit author:
git commit --amend --author "Your Name <your.name@mail.com>" 
Finish rebase:
git rebase --continue

Sunday, March 22, 2015

How to create git commit template

At work we integrated git with JIRA. If commit starts with our project name in JIRA and contains issue id, it will be automatically linked to that issue. For example:

PROJECT-10 Fix timezone

That pattern requires that every commit starts with the same characters "PROJECT-". Git supports commit templates, so every new commit message will include text from this template.

To make it work you just need to create a simple text file and configure git to use this file:
git config --local commit.template /path/to/git-commit-template.txt

How to find outdated python packages in your environment

The easiest way to find out if updated version of any installed package is available is to run that command:
pip list --outdated


There is also a special package for that task which is called pip-tools

Tuesday, December 9, 2014

bash: Colourful side-by-side command line diff

I have never liked default linux diff command. The more changes you make, the less informative it becomes. When you work with git it would be nice to have side-by-side comparison of original file and a new file with changes. Graphical tools like smartgit and meld do it really impressive.

But sometimes it is more comfortable to use command line tools. For colourful side-by-side git diff you can use cdiff. The simpliest way to install it is with pip package manager:
pip install cdiff

Then in your repository run:
cdiff -s

And the result is gorgeous!

The next tool is called icdiff. It does basicly the same, but with files. Install it with that command:
curl -s https://raw.githubusercontent.com/jeffkaufman/icdiff/release-1.2.0/icdiff \
| sudo tee /usr/local/bin/icdiff > /dev/null \
&& sudo chmod ugo+rx /usr/local/bin/icdiff


Use it like this:
icdiff file1 file2

Sunday, June 22, 2014

git: Как сохранить в файл все ваши коммиты

Для того, чтобы сохранить все коммиты в файл, надо выполнить команду:
git --no-pager log --author=jsnjack > log.txt