Git - Part 1

14 Dec 2019

Git it done!

This post gets the gist of git

Tracked, Untracked and more

  1. On your local repository, files are either tracked or untracked and tracked files could be one of unmodified, modified or staged.

A picture's worth a thousand words ~ Pro Git book

Explains:

  1. When you git init or git clone a repo, everything is unmodified because git automatically tracks all the files inside the local repo.
  2. You then make changes to some files. Those become modified.
  3. You add these files to the staging area with git add. They become staged.
  4. Finally when you’re happy with the changes, you git commit the files are then unmodified again.
  5. When you add the files to .gitignore, they are not tracked anymore or in other words untracked.

Branching

  1. a branch is a pointer to a commit
  2. HEAD is a pointer to the local branch you’re on

A picture for visual's sake HEAD pointing to a branch ~ Pro Git book

Rebase

Rebase branch A onto branch B is replaying all commits only belong to A onto B

The end commit introduced by rebase a branch onto another and the one by a merge is the same

Do not rebase commits that exist outside your repository and people may have based work on them. ~ Pro Git book

The last one roughly translates to:

Only rebase for local testing or before git push to make clean commits.