git: How to always pull with rebase
In order to have more human readable git branches, do
git pull --rebase
To always pull like this, write these lines to your ~/.gitconfig:
[pull]
rebase = true
..or use this oneliner
git config --global pull.rebase true
Note that this will break if you pull from other upstream branches like
git pull origin other-branch
If you keep rebasing by default, you can get "merge pulls" like this:
git pull --no-rebase origin other-branch
Related cards:
How to push to Git without running CI on GitLab CI, GitHub Actions, or Travis CI
If a project ist configured to spawn CI runners for tests or deployment when pushing to the Repo, a habit of pushing WIP commits regularly may conflict with that.
Here are two solutions that allow you to keep pushing whenever you feel like it.
#...
Configuring Git with .gitconfig
Basic configuration
Please keep this config simple. It should be a starting point for new developers learning Git.
[user]
name = Your Name
email = your.name@domain.com
[branch]
sort = -committerdate
[color]
ui = auto
[color "bra...
How to make Rational#to_s return strings without denominator 1 again
The way Rational#to_s
works on Ruby has changed from Ruby 1.9 on. Here is how to get the old behavior back.
You may want this for things where Rationals are being used, like when subtracting Date
objects from one another.
What's happening?...
How to "git diff" with a graphical diff tool
If you are fine with the default console diff most of the time but only sometimes want to use an external tool for viewing a diff, you can use git difftool
.
E.g. viewing git diff
with meld:
git difftool --tool=meld
For each file in ...
Customize tokenization of the MySQL FULLTEXT parser
The way MySQL's FULLTEXT tokenizer splits text into word tokens might not always be what you need. E.g. it splits a word at period characters.
Since the tokenizer has near-zero configuration options (minimum word length and stopwords list), you n...
Git: How to rebase your feature branch from one branch to another
In a nutshell: Use git rebase --onto target-branch source-commit
-
target-branch
means "branch you want to be based on" -
source-commit
means "commit before your first feature commit"
Let's say my-feature-branch
...
Git: how to work with submodules
Sometimes you might need to nest a git-project inside another git-project. The right strategy is to use submodules in this case.
How git submodules work
- Each submodule is a own git repository
- Once you commit changes in a submodule, the pa...
How to checkout submodules in Gitlab CI
Accessing other repositories in Gitlab CI is not straight forward, since the access rights of the current pipeline might not be sufficient enough.
One approach is to use project access tokens and clone the repositories via HTTPS.
- [Create a pro...
How to not leave trailing whitespace (using your editor or Git)
There is no reason to leave trailing whitespace characters in your project's files, so don't add any.
A git diff --check
will tell you if there are any and you should not commit when you see them. So go ahead and switch your editor/IDE to autom...
Invoices: How to properly round and calculate totals
While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals, it actually involves a lot of rules and caveats. It is very easy to create invoices where numbers don't add up and a few cents are missing....