Git

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

 Git

A simple presentation to show how Git works and the most important commands to use it.

Fabiano Almeida

May 29, 2013

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

26 slides
  1. WHAT IS GIT? • Free and Open Source • Distributed

    version control system • Designed to handle everything from small to very large projects • Fast and efficient • It’s a SCM tool like: Subversion, CVS, Perforce, ClearCase • Features like: cheap local branching, staging area and multiple workflows segunda-feira, 3 de junho de 13
  2. • Encourages you to have multiple local branches that can

    be entirely independent of each other • Frictionless context switching • Role-based codelines master => production test => to be validate all business rules feature01; feature02; feature03... • Feature based workflow • Disposable experimentation: create, experiment, delete BRANCHING AND MERGING - create a new branch, test your idea, commit a few times, switch back, apply a patch, switch back to where you are experimenting and merge it in - create new branches for each new feature you’re working on, switch back, merge all in, delete each branch - create a new branch, test everything what you want, delete it segunda-feira, 3 de junho de 13
  3. • Multiple backups • Every user essentially has a full

    backup of the main server • If occurs a crash or corruption, each of these copies could be pushed up to replace the main server • Any workflow • Almost endless number of workflows can be implemented with relative ease DISTRIBUTED segunda-feira, 3 de junho de 13
  4. GETTING A GIT REPOSITORY • git init => initializing a

    repository in an existing directory • Creates a new subdirectory named .git git add . git add *.c git add README git commit -m ‘initial commit’ • git clone git://github.com/fabianoalmeida/ticketer.git • Cloning an existing repository • git clone [url] [project_name] => change name locally segunda-feira, 3 de junho de 13
  5. RECORDING CHANGES TO REPOSITORY • git status => shows the

    current status of your files • your staged and unstaged changes • git add README => tracking new file • git diff => what you’ve changed but not yet staged • git commit => committing your changes git commit -m “message” => your commit message git commit -a -m “text” => skip the stage area • git rm README => removing file segunda-feira, 3 de junho de 13
  6. VIEWING THE COMMIT HISTORY • git log => show commit

    history git log -p => shows the diff introduced in each commit git log --pretty=online => prints each commit on a line git log --pretty=format: “%h %s” --graph => shows the graph between the commits • git log --since=2.weeks => limiting log output git log --pretty=”%h - %s” --author=gitster -- since=”2012-10-01” \ --before=”2012-11-01” --no- merge -- t/ • gitk => using a GUI to visualize history segunda-feira, 3 de junho de 13
  7. UNDOING THINGS • git commit --amend => changing the last

    commit git commit -m “initial commit” git add forgotten_file git commit --amend • Unstaging a staged file git add . git reset HEAD [the_wrong_file] • git checkout -- modified_file => unmodifying a modified file segunda-feira, 3 de junho de 13
  8. WORKING WITH REMOTES • git clone git://github.com/fabianoalmeida/ticketer.git cd ticketer git

    remote => showing your remotes # => origin • git remote -v => shows the URL that Git has stored • git remote add scmba git://github.com/scmba/ticketer.git => adding remote repository segunda-feira, 3 de junho de 13
  9. BRANCHING • git branch [branch_name] => creates new branch •

    git checkout -b [branch_name] => creates and switch to new branch • git checkout [branch_name]=> changes branch • git fetch scmba => fetches any work that has pushed git [push | pull] [remote-name] [branch-name] segunda-feira, 3 de junho de 13
  10. THANK YOU! • Fabiano Almeida • @almeidafabiano • fabianoalmeida.wordpress.com •

    [email protected] • github.com/fabianoalmeida • speakerdeck.com/fabianoalmeida/git segunda-feira, 3 de junho de 13

More Decks by Fabiano Almeida

Other Decks in Technology