Upload
catherine-sallas
View
36
Download
0
Embed Size (px)
DESCRIPTION
Hands on Git. Presented at: Nextbridge LHR C1 Presented by: Muhammad Rizwan Arshad (PSE) VTeams March 07, 2013. Introduction. Git is a version control system Created for a single task Managing changes to your files Track every change a software project. Files and Folders. - PowerPoint PPT Presentation
Citation preview
Hands on Git
Presented at:Nextbridge LHR C1
Presented by:Muhammad Rizwan Arshad
(PSE) VTeams
March 07, 2013
Introduction
Git is a version control systemCreated for a single taskManaging changes to your filesTrack every change a software project
Files and Folders
Local VCS
Centralized VCS
Distributed VCS
The Birth of Git
ReliabilityEfficient management of large projectsSupport for distributed developmentSupport for non-linear development
Installation
For Windows users, this will install a special command shell called Git Bash.
OS X and Linux users can access Git from a normal shell.
To test your installation, open a new command prompt and run ”git –version”.
Initialize the Git Repository
cd /path/to/my-git-repocd ~/Desktop/my-git-repogit init
View the Repository Statusgit status
# On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # index.html nothing added to commit but untracked files present (use "git add" to track)
Stage a Snapshot
git add index.html git status
# Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: index.html
Commit the Snapshotgit commitSaving a version of your project is a two step
process:1. Staging. Telling Git what files to include in
the next commit.2. Committing. Recording the staged snapshot
with a descriptive message.
View the Repository History
git logo commit
b650e4bd831aba05fa62d6f6d064e7ca02b5ee1b
o Author: unknown <user@computer.(none)> o Date: Wed Jan 11 00:45:10 2012 -0600
Configure Git
git config --global user.name "Your Name" git config --global user.email
Status output vs. Log output
The fundamental Git workflow
Basic Commands git init
Create a Git repository in the current folder. git status
View the status of each file in a repository. git add
<file>Stage a file for the next commit. git commit
Commit the staged files with a descriptive message. git log
View a repository’s commit history. git config --global user.name "<name>“
Define the author name to be used in all repositories. git config --global
user.email <email>Define the author email to be used in all repositories.
Undoing Changes
git log --oneline1c310d2 Add navigation links 54650a3 Create blue and orange pages b650e4b Create index page
View an Old Revisiongit checkout 54650a3git tag -a v1.0 -m "Stable version of the
website“Return to Current Version
git checkout masterView the Stable Commit
git checkout v1.0Undo Uncommitted Changes
git reset –hardgit clean -f
Resetting vs. Reverting
Commands:git checkout <commit-id>
View a previous commit.git tag -a <tag-name> -m "<description>“
Create an annotated tag pointing to the most recent commit.
git revert <commit-id>Undo the specified commit by applying a new commit.
git reset --hardReset tracked files to match the most recent commit.
git clean -fRemove untracked files.
git reset --hard / git clean -fPermanently undo uncommitted changes.
Branchesgit branch
List all branches.git branch <branch-name>
Create a new branch using the current working directory as its base.git checkout <branch-name>
Make the working directory and the HEAD match the specified branch.
git merge <branch-name>Merge a branch into the checked-out branch.
git branch -d <branch-name>Delete a branch.
git rm <file>Remove a file from the working directory (if applicable) and stop
tracking the file.
Rebasinggit rebase <new-base>
Move the current branch’s commits to the tip of <new-base>, which can be either a branch name or a commit ID.
git rebase -i <new-base> Perform an interactive rebase and select actions for each commit.
git commit --amend Add staged changes to the most recent commit instead of creating a
new one.git rebase --continue
Continue a rebase after amending a commit.git rebase --abort
Abandon the current interactive rebase and return the repository to its former state.
git merge --no-ff <branch-name> Force a merge commit even if Git could do a fast-forward merge.
Questions ?Suggestions are welcome.
Thank you.