The seven rules of a great git commit message
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
Related cards:
Squash my last X commits together using Git
You can do this fairly easily without git rebase
or git merge --squash
. In this example, we'll squash the last 3 commits.
If you want to write the new commit message from scratch, this suffices:
git reset --soft HEAD~3 && git commit
If ...
Find out when a keyword (method name, constant) is added or removed in git
When refactoring it is sometimes useful to see when a method or constant was introduced or removed.
git log -G'method_name'
git log -G'ConstantName'
If you see that a method is no longer used then you are safe to remove it. You can also ...
rebasing changes from a development branch onto another branch
If you have changes on a branch which you want to apply to another branch which has a different history you might not want to merge or rebase. This method allows you to identify a series of commits and replay them onto your destination branch. For...
Getting started with Git Log
The easy option:
git log --graph --decorate --oneline
-
--graph
draws a graph indicating commits (implies --topo-order) -
--decorate
shows any ref names (tags and branches) -
--oneline
shows the start of the commit sha and the commit tit...
Nginx rewrite rules for redirecting
Here's an example of how you can use match replacements in nginx redirect rewrite rules that can be used within a server
block:
Here's a complete example using the last one in the list on the staging site. So where you had:
`rewrite (?i)^/...
Bash: Batch rename files using the command line
Need to change the file extension for a bunch of files in your git repository? try:
find app/ -name '*.css.scss' -exec sh -c 'git mv "$0" "${0%.css.scss}.scss"' {} \;
This particular command finds all .css.scss files in the app folder and then...
Run a single test in Test::Unit
To run a single test file:
rake test:units TEST=test/unit/post_test.rb
rake test:functionals TEST=test/functional/posts_controller_test.rb
rake test:integration TEST=test/integration/admin_news_posts_test.rb
You may even run a single...
Connecting to MySQL running in a vagrant box
If you want to use something like Sequel Pro to connect to a database running within a vagrant vm you need to edit the /etc/mysql/my.cnf
file and change the bind-address
setting from 127.0.0.1
to 0.0.0.0
and restart mysql. `sudo service my...