Git

Version control for professionals

Git

Version control for professionals

Miguel D. Quintero

migueldavidq@gmail.com

Problems with not having version control.

Centralized vs Distributed

Centralized

Distributed

Git Qualities

Git is for the big ones

Where Git comes from. History of Git: Linus Torvalds

In 2002, the Linux kernel project began using BitKeeper, a proprietary software.
In 2005 it was no longer offered free of charge.

"unpleasant person" - "persona desagradable"

Git as "the stupid content tracker"

What is Git

Git is a distributed source code control system or SCM.

What is a git repo ?

Getting Started with Git

git config

        
$ git config --global user.name "USERNAME"
$ git config --global user.email "EMAIL@EMAIL.com"
		
      

Creating a git repo

        
$ git init
$ git add .
$ git commit -m "init"

git init DIRECTORY
		
      

Staging

Working with Git

        
$ git add README.md
$ git commit -m "DESCRIPTIVE MESSAGE"
$ git status
		
      

$ git add .

$ git status -u

Git Add

        
$ git add README.md
$ git add *.txt
$ git add docs/*.txt
$ git add docs/
$ git add --all
$ git add .
		
      

Git Status

        
$ git status



$ git status -h 
      
      

Git Commit

        
$ git commit -m  "DESCRIPTIVE MESSAGE"



$ git commit -h 
		
      

What is a hash?

History

        
$ git log

$ git log --summary
$ git log --oneline
$ git log --follow --oneline FILE
$ git log --pretty=format:'%h - %cn - %s' --abbrev-commit
		
      

View changes

        
$ git diff

$ git diff --staged
		
      

Git Checkout

        
$ git checkout master

$ git checkout COMMIT
$ git checkout COMMIT FILE
$ git checkout HEAD hello.py
		
      

Undoing Changes

        
$ git revert COMMIT

$ git checkout COMMIT
$ git checkout COMMIT FILE

$ git reset FILE
			
      

Summary

        
$ git config
$ git init
$ git add
$ git commit
$ git status
$ git log
$ git diff
$ git revert
$ git checkout
$ git reset
			
      

Using Branches

Git Branch

        
	$ git branch
	$ git branch BRANCH-NAME

	$ git branch -d BRANCH-NAME
	$ git branch -D BRANCH-NAME
	$ git branch -m NEW-NAME
			
      

Git Branch

        
	$ git branch BRANCH-NAME

	$ git checkout BRANCH-NAME

	$ git checkout -b BRANCH-NAME
			
      

Git Merge

        

		$ git merge BRANCH-NAME

		$ git merge --no-ff BRANCH-NAME

			
      

Remote

Working with remote repos




Git remote

        
$ git remote
$ git remote -v
$ git remote add NAME URL
$ git remote rm NAME
$ git remote rename OLD-NAME NEW-NAME
			
      

Git remote

        
	https://github.com/Mayccoll/Linux.git

	ssh://user@host/path/to/repo.git

	git@github.com:Mayccoll/Linux.git
			
      

Git clone

        
$ git clone	https://github.com/Mayccoll/Linux.git

$ git clone	ssh://user@host/path/to/repo.git

$ git clone	git@github.com:Mayccoll/Linux.git
			
      

Git Clone

        
  git clone git@github.com:mayccoll/Linux
  ___ _____ ___ __________ ________ _____
   1    2    3    4          5        6

   1. Command
   2. Argument

   3. host user
   4. host
   5. User
   6. Folder
			
      

Git Push

        
$ git push BRANCH

$ git push origin master
			
      

Git fetch

        
$ git fetch REMOTE

$ git fetch REMOTE/BRANCH

$ git fetch origin
			
      

Git Pull

        
$ git pull REMOTE

=

$ git fetch REMOTE
$ git merge REMOTE/BRANCH
			
      

Git Branch

        
$ git branch -a

$ git branch -r
			
      

Summary

        
$ git branch
$ git checkout -b
$ git merge
$ git remote
$ git clone
$ git push
$ git fetch
$ git pull
			
      

Learn

Utils

GUIs

GUI Clients

Repo Github