Home

Search IconIcon to open search

Git

A version control system. Maybe not the best in all aspects, but the most popular. Sane people use git clients like Sublime Merge or Magit.

Basic commands

Other stuff

# Git config

To view config: git config --list
Don’t forget to set a local timezone: git config --global log.date local UPD: not sure if it works! And not sure if it’s even needed.

# .gitignore

If you commit some file and then decide to not track it and add it to .gitignore, it still will be tracked. Tracked files are never ignored, see git - File is not ignored despite adding it to .gitignore.

As for a separate .gitignore for each branch, It’s kinda complicated. See this gist and this SO question.

# Patches

I still don’t quite understand how they work. They contain commit hashes, so they should only be applicable on the same repo, but I was somehow able to apply it to a repo with wiped out commit history.

Tip: to generate a patch from a commit on github, just add .patch to the commit URL.

# Commit info structure

Example:

1
2
3
4
5
6
tree 1334e254df78294aee11e6c914483bd7837c6930
parent 56ad2cf5d956fbc3860fbdc1c15a0073cae21223
author demicuz <pure.demicube@gmail.com> 1654647098 +0300
committer demicuz <pure.demicube@gmail.com> 1654647663 +0300

initial commit

Use git cat-file commit <some-commit> to view it. Yes, there is an author, and a committer. See more here. And here’s how to change committer and author.

# Submodules

1
2
git submodule add git@github.com:johndoe/leftpad # add a submodule
git submodule update --remote --merge # to update submodules