Back to git

Back to git, again. This time paying more attention and not rushing through the book. The last time I was trying to learn very fast to become a teacher of git, now I only want to master it. This article will probably evolved and will include more and more things for me to remember and if I do it well avoid using duckduckgo for each git command.

Why do you need git, You ask? It is made to experiment, thanks to git you can freeze the state of all the files in a directory, then change stuff and if you are not happy with the result rollback to the initial state. Even better with git you can go back to any previous saved state (known as commit)

The book I use is Git by Ryan Hodson (Amazon link). It is FREE.

Basic 1 - the fundamental git workflow

Flow diagram The stage/commit process

git configuration

  • git init Create a Git repository in the current folder
  • git config --global "<Name>" define the author name to be used in all repositories
  • git config --global "<email>" define the author email to be used in all repositories

Commands to save changes

  • git add <file> does the stage arrow in the diagram. Stage a file for the next commit.
  • git commit -m "commit message" move the snapshot content to git history. It is now possible to go back

Commands that show the state of files and repository

  • git status - view the status of each file in a repository
  • git log view a repository commit list history
  • git log --oneline same as above but much human friendly

Commands that undo changes


Commands that manage branches


Commands that manage remote repositories (like github)


Commands that manage tags



Before first usage of Git

git config --global "<Name>"
git config --global "<email>"

create and convert a folder named test to a Git repository

mkdir test
cd test
git init

After creating a file staging it

git add
git status

After staging committing it

git commit -m "Creation of"
git log --oneline
comments powered by Disqus