background preloader

Git Tasks

Facebook Twitter

A Hacker's Guide to Git. A Hacker’s Guide to Git is now available as an e-book.

A Hacker's Guide to Git

You can purchase it on LeanPub. Introduction Git is currently the most widely used version control system in the world, mostly thanks to GitHub. By that measure, I’d argue that it’s also the most misunderstood version control system in the world. This statement probably doesn’t ring true straight away because on the surface, Git is pretty simple. Once you start talking about branching, merging, rebasing, multiple remotes, remote-tracking branches, detached HEAD states… Git becomes less of an easily-understood tool and more of a feared deity.

I think a big part of this is due to many people coming to Git from a conceptually simpler VCS – probably Subversion – and trying to apply their past knowledge to Git. Basically, Subversion fits in nicely with our existing computing paradigms. That’s why trying to understand Git in this way is wrong. Repositories At the core of Git, like other VCS, is the repository. A Visual Git Reference. If the images do not work, you can try the Non-SVG version of this page.

A Visual Git Reference

SVG images have been disabled. (Re-enable SVG) This page gives brief, visual reference for the most common commands in git. Once you know a bit about how git works, this site may solidify your understanding. If you're interested in how this site was created, see my GitHub repository. Explain Git with D3. We are going to skip instructing you on how to add your files for commit in this explanation.

Explain Git with D3

Let's assume you already know how to do that. If you don't, go read some other tutorials. Pretend that you already have your files staged for commit and enter git commit as many times as you like in the terminal box. git tag name will create a new tag named "name". Creating tags just creates a new tag pointing to the currently checked out commit. Git concepts simplified (1) Sitaram Chamarty (sitaramc@gmail.com) If you're viewing this on "gitolite.com", please be aware that's only an artifact of some very lazy DNS and hosting decisions I made.

git concepts simplified (1)

Just think of it as "sitaramc.github.com" instead, because these pages really have nothing to do with gitolite per se. They're about git in general. This presentation uses HTML Slidy, a simple presentation software from the W3C. Although there's a help button in the footer of each presentation, it's missing some important stuff, so here's a smaller but more complete summary of the keyboard controls.

<To search> for stuff in the full document using your browser's Ctrl-F, first view all slides (press the "A" key).

Use bisect to track source of issue

About git HEADs. Lab 13 - Git Immersion - Brought to you by Neo. Goals Learn how to tag commits with names for future reference Let’s call the current version of the hello program version 1 (v1).

Lab 13 - Git Immersion - Brought to you by Neo

Tagging version 1 01 Execute: Now you can refer to the current version of the program as v1. Tagging Previous Versions 02 Let’s tag the version immediately prior to the current version v1-beta. If the v1^ notation gives you any trouble, you can also try v1~1, which will reference the same version. Git-checkout(1) Git checkout [-q] [-f] [-m] [<branch>] git checkout [-q] [-f] [-m] [--detach] [<commit>] git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>] git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>… git checkout [-p|--patch] [<tree-ish>] [--] [<paths>…] Updates files in the working tree to match the version in the index or the specified tree.

git-checkout(1)

If no paths are given, git checkout will also update HEAD to set the specified branch as the current branch. git checkout <branch> To prepare for working on <branch>, switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>. Git reset. In this section, we will discuss the available 'undo' Git strategies and commands.

Git reset

It is first important to note that Git does not have a traditional 'undo' system like those found in a word processing application. It will be beneficial to refrain from mapping Git operations to any traditional 'undo' mental model. Additionally, Git has its own nomenclature for 'undo' operations that it is best to leverage in a discussion. This nomenclature includes terms like reset, revert, checkout, clean, and more. A fun metaphor is to think of Git as timeline management utility. This tutorial provides all of the necessary skills to work with previous revisions of a software project.

Finding what is lost: Reviewing old commits The whole idea behind any version control system is to store “safe” copies of a project so that you never have to worry about irreparably breaking your code base. Each commit has a unique SHA-1 identifying hash. Checking out an old file does not move the HEAD pointer. Summary.

Patching

Branching best practices. Working with remotes & github. Use tags for versioning. Merge files across repos. Rmdir from repo.