Skip to content

Instantly share code, notes, and snippets.

@tranberg
Last active October 24, 2017 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tranberg/af7f1dfaf272b2b12e3ca6a69e34a5f0 to your computer and use it in GitHub Desktop.
Save tranberg/af7f1dfaf272b2b12e3ca6a69e34a5f0 to your computer and use it in GitHub Desktop.
Git happens - introduction, tutorials and references

Git happens

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).

Tutorials

Great video tutorials:

Hands-on tutorials:

Config

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"

Nice aliases

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'

Ignoring files

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.

Multiple remotes

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.

Help

  • 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.

Git-flow

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.

Visualisation

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.

Official documentation

  • 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.

Acknowledgements

Thanks to Karsten Lang (Klang) for mentoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment