Tech talks: Git basics

Tech talks: Git basics

We, in the company, have decided we want to start small regular education program where we can share best practices, new interesting technologies or whatever interesting we have seen and might be beneficial to others. We make up to one hour long session together where we present and discuss one selected topic. This blog is just short summary for future generations 🙂 First part is dedicated to Git.

Merge vs rebase

When you work in a team, you need to incorporate changes from others with your work. The default behaviour for git pull is that others’ changes are merged with your local commits. This leads to non-linear history and lots of “merge” commits.

Other alternative is git pull --rebase where source is updated to latest changes and your local work is “replayed” over the new code base. Only drawback is that in case of conflicts your original commit (based on the old code base) is lost and you can’t check your raw changes.

For more detailed discussion check this tutorial that also discuss other useful concept – feature branches.


Sometimes you don’t want to commit your current work but you want put them away for a while. E.g. you need to make urgent hotfix or you want to pull without commit. It can be easily done – git stash and when you want your changes back just call git stash pop. You can stash more work, check what do you have in stash etc. For more details check more stash commands.

Other tips

You can “download” server changes without affecting your work (as via git pull): git fetch. The “problem” is that you don’t see them in standard git log output. It can be easily solved: git log --all and similarly gitk --all.

But git log is not so nice be default. It has lot of configuration options but to write it all the time is not the way. Luckily you can define your git aliases, e.g. alias for lg defined as log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Add a comment

*Please complete all fields correctly

Related Blogs

Posted by Martin Bielik | August 31, 2016
Dynamic or static typing?
When it comes to dynamic and static typing there are big discussions and many opinions all around. I've collected following thoughts about this problem. Each one of it is questionable...
Posted by Martin Bielik | December 23, 2015
Tech talks: Concurrent tasks in Node.js
Nodeschool workshops have finally started in Bratislava (hosted by Progressbar). At the first meet-up we set up node environment and went through several workshoppers from the nodeschool site. There were people from...
Posted by Stanislav Miklik | December 7, 2015
Tech talks: Kibana introduction
This tech talks was quick presentation of our first steps in server monitoring. And at the same time it was simple introduction to Kibana and Elasticsearch. What to collect? We...