0% found this document useful (0 votes)
31 views13 pages

Introduction To Git - John Troon

The document provides an introduction to Git, including what it is, why it is useful, how to install and configure it, and how to perform basic commands and workflows like branching, merging, and using remote repositories. It covers topics such as initializing a Git repository, adding, committing, viewing logs and history, creating and switching branches, merging changes, and interacting with remote servers.

Uploaded by

Technical Novice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views13 pages

Introduction To Git - John Troon

The document provides an introduction to Git, including what it is, why it is useful, how to install and configure it, and how to perform basic commands and workflows like branching, merging, and using remote repositories. It covers topics such as initializing a Git repository, adding, committing, viewing logs and history, creating and switching branches, merging changes, and interacting with remote servers.

Uploaded by

Technical Novice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Introduction to Git

By John Troon
What is Git?
● Version Control System (VCS)
it's a VCS designed to handle very large projects
with speed and effciency.
● Distributed Source Code management
– Every Git working directory is a full-fleged
repository with full version tracking capabilities, not
dependent on network access or a central server.
Why Git
● Work offline
● Branching (made easy)
● Distributed (when back online)
● Clean (easy project tracking)
Install Git
● Debian based:
– `apt-get install git-core`
● Mac Ports:
– `port install git-core`
● RPM Based:
– `yum install git-core`
● Arch Linux:
– `pacman -S git-core`
Build Git from Source
● Download and uncompress the tar.gz source
– `tar xfz git-version.tar.gz
– `cd git-version`
● Make
– `make prefix=/usr/local all`
– `sudo make prefix=/usr/local install`
– `git --version`
Configure Git
● General Global Config
– `git config --global user.name “John Troon”
– `git config –global email '[email protected]'
– `git config –list`
● Alias:
– `git config –global alias.sts status`
● White Space diff
– `git config –global apply.whitespace nowarn`
Basic Git Commands
● Initialize
– `git init`
– `tree .git`
● Edit, Stage, Commit
– `git add .` or `git add filename`
– `git status`
– `git commit -m “First commit”` or `git commit -a -v`
– `git lsfiles` view tracked files
– `git rm unwantedFile` Remove files not to track.
Git Log
● View Git history with Sha1 hashes
– `git log`
– `git reflog`
● ASCII Graph
– `git log --stat`
● View Actual Difference
– `git log -p`
● View particular changes on a file
– `git log –patch Filename`
● Search Git Logs
– `git log -S 'string'
Branches
● Why Branch?
– When working on new experimental features.
– By default, you will be working on the master branch.
● Branch and switch to the new branch….
– `git branch new-feature`
– `git branch`
– `git checkout new-feature`
● Simple trick..
– Create and switch to a new brach based on the master repository.
– `git checkout -b new-feature master`
Merge Changes from a Branch
● Update Branch with new changes on Master
– `git rebase master` (still on the new-feature branch)
● Mearge Master with the new Branch
– Checkout to master `git checkout master`
– Check diffrecence `git diff master new-feature`
– Everything okay, merge! `git merge new-feature`
● Reset (Shit happens)
– `git rest --hard ORIG_HEAD`
● Conflict During Merge
– You'll have to read the error(s) and resolve them manually.
Remote Repository
● SSH and HTTPS access
– For demos, I'll be using github.com
– Create an account, SSH key pairs and a repository.
● Working……
– `git clone remote-project`
– `git commit -a -v` (after making changes…)
– `git push` (submit changes to remot repo)
– `git pull` (get changes from remote server)
– `git pull –rebase origin master` It's good to rebase instead of pull
since you will wind up with lot of “merge commit”.
Cool Resources
● gbrt
● Smart-pull
● Gitk
● Git working flow
– Centralised workflow
– Feature Branch workflow
– GitFlow workflow
– Forking Workflow
Questions?
John Troon
Email: [email protected]
Twitter: @johntroony

You might also like