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 user.name "<Name>" define the author name to be used in all repositories
  • git config --global user.email "<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

TODO

Commands that manage branches

TODO

Commands that manage remote repositories (like github)

TODO

Commands that manage tags

TODO

Combo

Before first usage of Git

git config --global user.name "<Name>"
git config --global user.email "<email>"

create and convert a folder named test to a Git repository

mkdir test
cd test
git init

After creating a file index.md staging it

git add index.md
git status

After staging index.md committing it

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