21
Now I get it!!! > git config --global -l | grep user user.name=Yoram Michaeli user.email=[email protected] http://www.tikalk.com

Now i git it!!!

Embed Size (px)

Citation preview

Page 1: Now i git it!!!

Now I get it!!!> git config --global -l | grep user

user.name=Yoram Michaeli [email protected]

http://www.tikalk.com

Page 2: Now i git it!!!

Version Control System (VCS)

Now I GIT it!!!

Page 3: Now i git it!!!

GIT origins and start-points

● Created by Linus Torvalds (created Linux as well)

● Linux kernel project● Meant to be

○ Fast distributed system○ Capable of handling large projects

● Command line interface● Official GIT site: http://git-scm.com● There are many available GUI tools> git help

usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] [-c name=value] [--help] <command> [<args>]Now I GIT it!!!

Page 4: Now i git it!!!

Let's GIT started

● Installation - depends on the OS

● Initial global configuration> git config --global user.name "Bill Gates"

> git config --global user.email [email protected]

> git config --global color.ui true

Now I GIT it!!!

Page 5: Now i git it!!!

Let's GIT going

● Start a new empty local repository> mkdir NowIGitIt> cd NowIGitIt> git initInitialized empty Git repository in ~/Documents/Tikal/git_demo/NowIGitIt/.git/ > git status# On branch master## Initial commit#nothing to commit (create/copy files and use "git add" to track)

Now I GIT it!!!

Page 6: Now i git it!!!

Common workflow - new file

Now I GIT it!!!

Step Command Output of git status command

Create file locally echo start > First.txt # On branch master## Initial commit## Untracked files:# (use "git add <file>..." to include in what will be committed)## First.txtnothing added to commit but untracked files present (use "git add" to track)

Add file to staging area

git add First.txt # On branch master## Initial commit## Changes to be committed:# (use "git rm --cached <file>..." to unstage)## new file: First.txt#

Commit changes git commit First.txt -m "First commit"output of command:master (root-commit) 30e3004] First commit 1 file changed, 1 insertion(+) create mode 100644 First.txt

# On branch masternothing to commit (working directory clean)

Page 7: Now i git it!!!

Common workflow - modified file

Now I GIT it!!!

Step Command Output of git status command

Change file locally echo changed > First.txt # On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: First.txt#no changes added to commit (use "git add" and/or "git commit -a")

Commit changes git commit First.txt -m "Second commit"output of command:[[master f1d433f] Second commit 1 file changed, 1 insertion(+), 1 deletion(-)

# On branch masternothing to commit (working directory clean)

Page 8: Now i git it!!!

GIT basic file flow

Now I GIT it!!!

Page 9: Now i git it!!!

GIT log - view history

Now I GIT it!!!

> git logcommit f1d433f5b79a10b9a12dc8277bc9aae62bff0cfaAuthor: Yoram Michaeli <[email protected]>Date: Fri May 3 14:58:51 2013 +0300

Second commit

commit 30e30041fdb8f97751ddc3f99da25a960b6d3b74Author: Yoram Michaeli <[email protected]>Date: Fri May 3 14:41:44 2013 +0300

First commit

Page 10: Now i git it!!!

GIT diff - where things matters...

> echo change2 > First.txt> git diffdiff --git a/First.txt b/First.txtindex 5ea2ed4..39c5733 100644--- a/First.txt+++ b/First.txt@@ -1 +1 @@-changed+change2

Now I GIT it!!!

Page 11: Now i git it!!!

Regretting what I've done...

Now I GIT it!!!

Action Command Output of git status command

Unstaging a file git reset HEAD First.txtoutput of command:Unstaged changes after reset:M First.txt

# On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: First.txt#no changes added to commit (use "git add" and/or "git commit -a")

Discard changes git checkout -- First.txt # On branch masternothing to commit (working directory clean)

Undoing a commit git reset --soft HEAD^ # On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: First.txt#

Page 12: Now i git it!!!

GIT collaboration

Now I GIT it!!!

Page 13: Now i git it!!!

GIT Repository clone

> git clone https://github.com/tikalk/NowIGitIt.git

● Clone an existing repository as a local repository

● Clones into current folder● Can be named differently than the origin

repository

Now I GIT it!!!

Page 14: Now i git it!!!

Add remote GIT repository

> git remote add origin https://github.com/tikalk/NowIGitIt.git

● Clone command add origin remote automatically

● More than one remote is possible● Use git remote remove <name> to remove a

remote

Now I GIT it!!!

Page 15: Now i git it!!!

Push to a remote repository

> git push -u origin master ● Push changes on local repository into a

remote repository● Will fail if there are conflicts● Fast-forward push is the best!

Now I GIT it!!!

Page 16: Now i git it!!!

Pull from remote repository

> git pull● Pull changes from remote repository into the

local repository● Will fail if there are conflicts● Fast-forward pull is the best!

Now I GIT it!!!

Page 17: Now i git it!!!

GIT Branching

> git branch unofficial> git branch* master unofficial> git checkout unofficialSwitched to branch 'unofficial'> git branch master* unofficial

Now I GIT it!!!

Page 18: Now i git it!!!

GIT Merging

> git checkout unofficial> echo "Now I GIT it" > README.txt> git add README.txt> git commit -m "Add README file"> git checkout master> git merge unofficial

Now I GIT it!!!

Page 19: Now i git it!!!

Add GIT tag

> git tag -a tag1 -m "first tag"> git tag -a tag2 -m "second tag"> git tagtag1tag2> git tag -d tag2> git tagtag1

Now I GIT it!!!

Page 21: Now i git it!!!

Now I GIT it!!!