Version Control System

Git

Git is a distributed version control system that tracks changes in any set of computer files.

Cool thing to show star history:

Resources

gh auth login

Git remove file that is already stored

git rm --cached -r <YOUR_files_or_folders>

Topics

Git Reset vs. Revert vs. Checkout reference

Commands

The git stash command helps you stash your work away and clear your working directory. Then when you checkout it will not carry over the new code with you.

Lessons from Ericsson

Make your personal branch in a way that it can track the master:

  1. git checkout -b personal/$USER/pdcch origin/master
  2. git pull -r (to rebase)
  3. cherry pick: git fetch ssh://ezalwya@gerrit.ericsson.se:29418/lte/ebb refs/changes/04/12367804/1 && git cherry-pick FETCH_HEAD

gerrit ex: link, to download the patch, I see 4 options.

  1. repo download
  2. checkout
  3. pull
  4. cherry-pick

Checkout: Fetches the latest changes. You should already have this repo downloaded. It does not merge those new changes but makes your working directory reflect them. And a name-less commit is created to include these changes in your working directory. And a detached HEAD pointing to it. You can merge them at your leisure later.

Pull: Fetches the changes AND merges them into the local branch of the same name.

Cherry-pick: Fetches the commit and plays it on top of the current local branch, thus creating an entirely new commit which happens to have same changes as the one it fetched.

Useful Tips

  1. Setup your ~/.gitconfig so you can use shortcuts. I have my own .gitconfig file so typing commands is faster.

NEW: Since joining Ericsson, I’ve realized that it is even more productive to exclude the space. However, to do that, the aliases need to be written in the shell, i.e. ~/.zshrc instead of ~/.gitconfig

For instance,

alias ga `git add`
alias gcm `git commit -m`
AliasCommand
gagit add
gbgit branch
gbv git branch -vv
gcmgit commit -m
gsgit status
gpgit push
gst
ga .
gcm "insert message"
gps
  1. What do you do if you just made a commit but then realize that flake8 has an error when you run it? Or you spot a typo in the commit message you just entered? Git will allow you to “amend” a commit:
g cm --amend "I am bad at spelling"