Slide 1

Slide 1 text

Git /ɡɪt/ http://git-scm.com Friday, 16 August 13

Slide 2

Slide 2 text

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency Initially designed and developed by Linus Torvalds for Linux Kernel development. Initial released: 7 April 2005 License: GNU General Public License v2 Friday, 16 August 13

Slide 3

Slide 3 text

Git Basics Setting up a Git repository Friday, 16 August 13

Slide 4

Slide 4 text

git init The git init command initialises a new Git repository. If you want to place a project under revision control, this is the first command you need to learn. git init Friday, 16 August 13

Slide 5

Slide 5 text

git clone The git clone command creates a copy of an existing Git repository. Cloning is the most common way for developers to obtain a working copy of a central repository. git clone Friday, 16 August 13

Slide 6

Slide 6 text

git config The git config is a convenient way to set configuration options for your Git installation. You’ll typically only need to use this immediately after installing git on a new development machine. git config Friday, 16 August 13

Slide 7

Slide 7 text

Git Basics Recording snapshots Friday, 16 August 13

Slide 8

Slide 8 text

git add The git add command moves changes from the working directory to the staging area. This gives you the opportunity to prepare a snapshot before committing it to the official history. git add <file/directory> Friday, 16 August 13

Slide 9

Slide 9 text

git commit The git commit takes the staged snapshot and commits it to the project history. Combined with git add, this defines the basic workflow for all Git users. git commit -m Friday, 16 August 13

Slide 10

Slide 10 text

Git Basics Inspecting a Git repository Friday, 16 August 13

Slide 11

Slide 11 text

git status The git status command displays the state of the working directory and the staged snapshot. You’ll want to run this in conjunction with git add and git commit to see exactly what’s going being included in the next snapshot. git status Friday, 16 August 13

Slide 12

Slide 12 text

git log The git log command lets you explore the previous revisions of a project. It provides several formatting options for displaying committed snapshots. git log Friday, 16 August 13

Slide 13

Slide 13 text

Undoing Changes Viewing old commits Friday, 16 August 13

Slide 14

Slide 14 text

git checkout The git checkout command serves 3 different functions: checking out files, checking out commits and checking out branches. git checkout Friday, 16 August 13

Slide 15

Slide 15 text

Undoing Changes Undoing public changes Friday, 16 August 13

Slide 16

Slide 16 text

git revert The git revert commands undoes a committed snapshot. When you discover a faulty commit, reverting is a safe and easy way to completely remove it from the code base. git revert Friday, 16 August 13

Slide 17

Slide 17 text

Undoing Changes Undoing local changes Friday, 16 August 13

Slide 18

Slide 18 text

git reset The git reset commands undoes changes to files in the working directory. Resetting lets you clean up or completely remove changes that have not been pushed to a public repository. git reset <file> Friday, 16 August 13

Slide 19

Slide 19 text

git clean The git clean commands removes untracked files from the working directory. This is the logical counterpart to git reset, which (typically) only operates on tracked files. git clean Friday, 16 August 13

Slide 20

Slide 20 text

Git Branches Git branches Friday, 16 August 13

Slide 21

Slide 21 text

git branch The git branch command is your general-purpose branch administration tool. It lets you create isolated development environments within a single repository. git branch Friday, 16 August 13

Slide 22

Slide 22 text

git checkout In addition to checking out old commits and old file revisions, git checkout is also the means to navigate existing branches. Combined with the basics Git commands, it’s a way to work on a particular line of development. git checkout Friday, 16 August 13

Slide 23

Slide 23 text

git merge The git merge command is a powerful way to integrate changes from divergent branches. After forking the project history with git branch, git merge lets you put it back together again. git merge Friday, 16 August 13

Slide 24

Slide 24 text

Rewriting Git History Rewriting Git history Friday, 16 August 13

Slide 25

Slide 25 text

git commit --amend Passing the --amend flag to git commit lets you amend the most recent commit. This is very useful when you forget to stage a file or omit important information from the commit message. git commit --amend Friday, 16 August 13

Slide 26

Slide 26 text

git rebase Rebasing lets you move branches around, which helps you avoid unnecessary merge commits. The resulting linear history is often much easier to understand and explore. git rebase Friday, 16 August 13

Slide 27

Slide 27 text

git rebase -i The -i flag is used to begin an interactive rebasing session. This provides all benefits of a normal rebase, but gives you the opportunity to add, edit, or delete commits along the way. git rebase -i Friday, 16 August 13

Slide 28

Slide 28 text

Remote Repositories Remote Git repositories Friday, 16 August 13

Slide 29

Slide 29 text

git remote The git remote command is a convenient tool for administering remote connections. Instead of passing the full URL to the fetch, pull, and push commands, it lets you use a more meaningful shortcut. git remote Friday, 16 August 13

Slide 30

Slide 30 text

git fetch Fetching downloads a branch from another repository, along with all its associated commits and files. But, it doesn’t try to integrate anything into your local repository. This gives you the chance to inspect changes before merging them with your project. git fetch Friday, 16 August 13

Slide 31

Slide 31 text

git pull Pulling is the automated version of git fetch. It downloads a branch from a remote repository, then immediately merges it into the current branch. git pull Friday, 16 August 13

Slide 32

Slide 32 text

git push Pushing is the opposite of fetching (with a few caveats). It lets you move a local branch to another repository, which serves as a convenient way to publish contributions. git push Friday, 16 August 13

Slide 33

Slide 33 text

Git Workflow Centralised Workflow Friday, 16 August 13

Slide 34

Slide 34 text

Feature Branch Friday, 16 August 13

Slide 35

Slide 35 text

GitFlow Friday, 16 August 13

Slide 36

Slide 36 text

Forking Friday, 16 August 13