1 / 24

Hands on Git

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.

Download Presentation

Hands on Git

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hands on Git Presented at: Nextbridge LHR C1 Presented by: Muhammad RizwanArshad (PSE) VTeams March 07, 2013

  2. Introduction • Git is a version control system • Created for a single task • Managing changes to your files • Track every change a software project

  3. Files and Folders

  4. Local VCS

  5. Centralized VCS

  6. Distributed VCS

  7. The Birth of Git • Reliability • Efficient management of large projects • Support for distributed development • Support for non-linear development

  8. 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”.

  9. Initialize the GitRepository • cd/path/to/my-git-repo • cd~/Desktop/my-git-repo • gitinit

  10. View the Repository Status • gitstatus #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)

  11. Stage a Snapshot • gitaddindex.html • git status #Changes to be committed: # (use "gitrm --cached <file>..." to unstage) # # new file: index.html

  12. Commit the Snapshot • gitcommit • Saving a version of your project is a two step process: • Staging. Telling Git what files to include in the next commit. • Committing. Recording the staged snapshot with a descriptive message.

  13. View the Repository History • gitlog • commitb650e4bd831aba05fa62d6f6d064e7ca02b5ee1b • Author:unknown <user@computer.(none)> • Date:Wed Jan 11 00:45:10 2012 -0600

  14. Configure Git • gitconfig--globaluser.name"Your Name" • gitconfig--globaluser.emailyour.email@example.com

  15. Status output vs. Log output

  16. The fundamental Git workflow

  17. Basic Commands • gitinit • Create a Git repository in the current folder. • gitstatus • View the status of each file in a repository. • gitadd • <file>Stage a file for the next commit. • gitcommit • Commit the staged files with a descriptive message. • gitlog • View a repository’s commit history. • gitconfig--globaluser.name"<name>“ • Define the author name to be used in all repositories. • gitconfig--global • user.email<email>Define the author email to be used in all repositories.

  18. Undoing Changes • gitlog--oneline 1c310d2Add navigation links 54650a3Create blue and orange pages b650e4bCreate index page

  19. View an Old Revision • gitcheckout54650a3 • gittag-av1.0-m"Stable version of the website“ • Return to Current Version • gitcheckoutmaster • View the Stable Commit • gitcheckoutv1.0 • Undo Uncommitted Changes • gitreset–hard • gitclean-f

  20. Resetting vs. Reverting

  21. Commands: • gitcheckout<commit-id> • View a previous commit. • gittag-a<tag-name>-m"<description>“ • Create an annotated tag pointing to the most recent commit. • gitrevert<commit-id> • Undo the specified commit by applying a new commit. • gitreset--hard • Resettracked files to match the most recent commit. • gitclean-f • Removeuntracked files. • gitreset--hard / gitclean-f • Permanently undo uncommitted changes.

  22. Branches • gitbranch • List all branches. • gitbranch<branch-name> • Create a new branch using the current working directory as its base. • gitcheckout<branch-name> • Make the working directory and the HEAD match the specified branch. • gitmerge<branch-name> • Merge a branch into the checked-out branch. • gitbranch-d<branch-name> • Delete a branch. • gitrm<file> • Remove a file from the working directory (if applicable) and stop tracking the file.

  23. Rebasing • gitrebase<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. • gitrebase-i<new-base> • Perform an interactive rebase and select actions for each commit. • gitcommit--amend • Add staged changes to the most recent commit instead of creating a new one. • gitrebase--continue • Continue a rebase after amending a commit. • gitrebase--abort • Abandon the current interactive rebase and return the repository to its former state. • gitmerge--no-ff<branch-name> • Force a merge commit even if Git could do a fast-forward merge.

  24. Questions ? Suggestions are welcome. Thank you.

More Related