Git Tips

Commit Messages

Write your commit comments in the past tense, when others view them, it will be in the past and when you commit, it will be work you did prior to committing and should be a summary. Some people use a "CATEGORY: message" format, so for example:

BUGFIX: Resolved file error
DOC: Fixed README.md
ENHANCE: Added more cowbell
BUGFIX: fixed crash on http read
CLEANUP: removed old tests

This works well for documentation but limiting the categories obviously helps. In addition it is worth reading How to Write a Git Commit Message which has some good advice.

Proxies

Git over https works quite happily behind a proxy server. If there is a proxy setup for your browser then you will most likely need to use a proxy for git, especially if it is hosted externally. Fortunately this is easy to do, simply execute the following, with the correct details, of course:
git config --global http.proxy http://10.21.43.195:8080
On Linux git will respect the standard environment variables if you have them set.

Setting up Git

Well, this is a much longer and more complicated thing than you might think! See How Core Git Developers Configure Git for some interesting options.

Line Endings

There are times when you can ignore this, however, sometimes you need to be explicit about how line endings are dealt with. If you have Windows and macOS users then it is better to be explicit than rely on people doing the right thing, same applies when you have Windows script files and macOS or Linux script files.

The recommended technique is to set "autocrlf" to false and use a git attributes file. I would recommend setting this globally, you can check where it is set (local or global) and what it is with the following command:
git config --show-scope core.autocrlf (you can replace "core.autocrlf" with "--list" to see all)
Then create a .gitattributes in the root of your repository and set it as follows:

# Note: core.autocrlf should be false

# set default for all text files to lf
* text=auto eol=lf

# override Windows files to be crlf
*.bat text eol=crlf
*.cmd text eol=crlf

Once this is done, and assuming you have an existing repository with commits it is recommended that you use git add --renormalize . to update/fix the files and then commit and push these changes. See Git Config for more details on some of this.