This is supposed to be a short introduction to Git and an overview of related tutorials and tools.
What is Git?
Git is not Dropbox. That means Git is not syncing or backing up automatically. You decide when and what changes you want to write to the Git history.
Git is not GitHub. Git is a tool that is independent of any company. What companies like GitHub/GitLab/Bitbucket sell is a service for you to host your repositories on the public internet to share and collaborate with the world.
Git is a free and open source distributed version control system initially developed by Linus Torvalds (the Linux kernel guy).
Great video tutorials:
Presenting yourself to git:
git config --global user.name "your name" git config --global user.email "your email"
or just for a project:
git config --local user.name "your name" git config --local user.email "your email"
git config --global alias.lol 'log --oneline --graph --all --decorate' git config --global alias.unstage 'reset --'
The first alias git lol prints a nice overview of the Git history when called from the command line. The second alias git unstage is a neat way to undo git add when you have accidentally added too many files to your repository.
For more aliases, see Klang's tutorial.
Initialising a repository (example):
cd <project folder> git init git add . git commit -m 'initial'
You can specify individual files, file types, or patterns of file names to be ignored by git in a .gitignore file inside your repository. This is particularly useful for excluding temporary files such as output from a build process. You can find documentation and examples here.
Git is a distributed version control system. This means that there is not a particular master repository for your project. It can live on all your computers and across several remote repositories. As an example you can push/pull your local repository to both an internal and external Git server. You decide. Look here to get started.
- Git pretty: for when you have made a mess.
- Git cheatsheet: an interactive visualisation to help you understand the differences between: stash, workspace, index, local and remote repositories.
When you have mastered the basics of Git it's time to learn about A successful Git branching model called git-flow. This is particular useful for lager projects with multiple developers and branches. Documentation.
If you want to visualise the development of your project through the Git history you can do so simply by using Gource - a software version control visualization tool.
- Documentation and guides: git-scm.com
- Free book: git-scm.com/book. This includes everything. Even how to set up your own git server similar to hosted services.
Thanks to Karsten Lang (Klang) for mentoring.