Git

Nice display of the current tree

git log --graph --all --format=format:"%x09%C(yellow)%h%C(reset) %C(green)%ai%x08%x08%x08%x08%x08%x08%C(reset) %C(bold
white)%cn%C(reset)%C(green)%d%C(reset)%n%x09%C(white)%s%C(reset)" --abbrev-commit "[email protected]"

An alternative:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

You can also make an alias. Copy and paste the line below on your terminal:

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

And every time you need to see your log, just type in

git lg

Or, if you want to see the lines that changed

git lg -p

Source: https://coderwall.com/p/euwpig

NB: If you want to see a list of aliases set up on your linux box, just type alias at the prompt.

Simply add color to your git environment:

git config --global color.ui auto

Source: http://git-scm.com/book/en/Customizing-Git-Git-Configuration

Tutorial

Learn git from your browser: https://try.github.io/levels/1/challenges/1

Delete current tag

git tag -d 12.15
git push origin :refs/tags/12.15

Stash current work

git stash save
git stash pop

Push

To avoid doing all the time:

git push origin <your-feature-branch>

You can do:

git push origin <your-feature-branch> -u

You next, you will just have to do:

git push

Find which commit is breaking the test with 'git bisect'

You may be in situation where you come back from holidays and find the tests that were passing before broken.

Git can help to find which commit produced the failure.

To start bisect, run:

git bisect start

You know that the tests are failing so you indicate it with:

git bisect bad

You checkout an earlier revision when you know that the tests were passing (git log can help):

git checkout <the_failing_revision>

Then run the tests, and if they are passing, indicate it:

git bisect good

Once you have indicated that once it was bad and once it was good. You can leave git bisect do the job automatically:

git bisect run <command_that_run_the_tests>

You can now grab a coffee and come back few minutes later to see what commit made the tests failed.

Finally, you also need to come back to the original revision:

git bisect reset

Sources:

What is the original commit of a git repository?

You know git log to see the history of he commits.

Once you get the results of git log, you can do 'G' (capital G) to inverse the order of commits and see the first one in time.

Revert all the changes you did

git checkout -f

Comments

Comments powered by Disqus