Different ways of squashing commits

Jul 21, 2018

While creating a Pull Requests it’s good to squash all of our intermediate commits into one to avoid clutter in the git log, simplify analysis and allow for simple code revert when necessary. Solution #1 # Some time ago I’ve found project made by Jake Wharton. It’s really useful, handy and allows us to rebase and squash commits quite easily. We can just call: curl | sh then edit our commit messages and push the changes. ...

Avoiding merging master to master branch in Git

Mar 25, 2018

Problem # If you are working with Git Version Control System, probably you have seen a commit messages in your git log like: Merge branch 'master' to 'master' or something similar. You might have even pushed such commits! Don’t worry, so did I ;-). In this article I’m going to explain why is it happenning and how to avoid it. Such situation happens when you performed changes locally and at the same time someone else performed changes on the same branch as well, commited and pushed them to the remote repository. ...

Meet and Code 2017 - "Git – tips & tricks" presentation

Oct 21, 2017
git, conferences

Recently, during Meet & Code event organized by Media 3.0 and SAP Hybris, I’ve gave a talk for university and high-school students about basics of Git. Presentation was titled Git - tips & tricks and was organized at the Silesian Univeristy of Technology in the AEI Department where I was studying a few years ago. Presentation covered quite essential usage of Git, which could be helpful for people who are planning to learn it from the scratch. ...

Review your changes in the code before the commit

Mar 26, 2017

Most of the people use git as follows. they create a feature branch they make some changes they add all the changes: git add -A they commit changes: git commit -m "I've done changes" they push it: git push There’s a problem with such approach. When we created a lot of changes, it may happen that we forgot to delete something and we pushed some garbage to the remote repository. ...

My approach to Git aliases

Mar 12, 2017

While we are working with Version Control Systems like Git, it’s good to adapt them to our needs to perform daily work in a more productive way. People often create so-called Git aliases, which are shortcuts for longer commands. E.g. you can edit your .gitconfig file, which is usually located in your home directory and place a few aliases in the [alias] section. For example: [alias] ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate Then you can type: git ls in your Git repository to see pretty Git log. ...

Working with different Git configs

Mar 10, 2017

Short introduction # Sometimes people need to specify multiple values for single .gitconfig file or they want to share just part of the configuration between two machines. There are different approaches for that. I can show you mine. Different configs for different Operating Systems # On my private computer, I use Linux. I use Git for my private projects and I use my private e-mail address there. At the same time, I use Git at work on macOS with exactly the same Git configuration, but with a different e-mail address. ...

Automate boring stuff

Jan 1, 2017
git, python

Introduction # In my current company all the people who perform creative work (mostly programmers) need to prepare so-called PKUP report. PKUP stands for Podwyższone Koszty Uzyskania Przychodu in the Polish language. It’s legal regulation in Poland, which allows paying a lower income tax due to the particular type of work. For the regular employee, it means that he or she will simply get a bit higher salary per month. ...

3 questions about your Git repository

Dec 28, 2015
git, python

Introduction # Can you answer the following questions about your Git repository? Does development branch has all changes from master branch? Is your gitlog a crap? How old are your branches? If not, but you want to know answers, you’re lucky, because I prepared 3 simple scripts for you, which can help to find it out. Does development branch has all changes from master branch? # git-branch-comparator is a python script, which checks if development branch has all changes from master branch in Git repository. ...

Checking consistency of git branches

May 14, 2015
git, python

Recently I’ve created a simple Python script, which checks whether ‘development’ branch has all changes from ‘master’ branch in a Git repository. It’s important when we work in a Git Flow. Branch inconsistency may occur when change with hot-fix will be committed to ‘master’ branch and we forget to merge ‘master’ branch back to ‘development’ branch to have our hot-fix in a ‘development’ version of the project as well. We should keep branch consistency to avoid merge conflicts and problems with release of the project in the future. ...

Basics of Git

Nov 27, 2014

Introduction # Git is very popular Version Control System used in many software projects today. In my opinion, it’s the best VCS available today. In order to start your adventure with this tool, you should know its basic commands and features. There are graphical tools, which allows to use Git without terminal, but I recommend you to use terminal. With CLI you can work faster, you can understand Git better and you have more control over your repository. ...