View
256
Download
0
Category
Tags:
Preview:
Citation preview
Before and AfterWithout version control system
ProjectDirectory
bytes
bytes
ProjectDirectory
bytes
bytes
ProjectDirectory
bytes
bytes
bytes
Day 1 Day 2 Day 3
ProjectDirectory
bytes
bytes
ProjectDirectory
bytes
bytes
ProjectDirectory
bytes
bytes
bytes
Day 1 Day 2 Day 3
With version control system
High level structure
Centralized
CentralRepository
TeamLead
Sr.Dev
Sr.Dev
Jr.Dev
Jr.Dev
Jr.Dev
Jr.Dev
Distributed
TeamLead
Sr.Dev
Jr.DevJr.Dev
Sr.Dev
Jr.DevJr.Dev
Features
Distributed development.
Every Developer has full copy.
Most operation are local, so its fast.
Strong support for non-linear development.
Create repository
$ git init
MyProjectrepo
Repository created
Clone a repository
$ git clone <url>
Local repo
Cloning complete repository to local
Remoterepo
Adding files/directories (modified)
$ git add <file/dir name>
Stagingarea
Workingdirectory
stage files
Committing changes
$ git commit -am “<commit message>”
Local repo
Stagingarea
commits
Why commit is important :
Each commit gets an SHA1
hash key.
What you put in is what
you get out.
Reset changes
$ git reset$ git reset --hard
Local repo
Stagingarea
Workingdirectory
Add – for modifiedOr new files
Remove for stagingarea
Key points
Git add :
– To add new files.
– To add files to staging area (shortcut: commit -a).
Git reset :
– Clear staging area.
– Clear local changes with “--hard” option.
Status of untracked/modified files
$ git status
Local repo
Stagingarea
Workingdirectory
stage files
commits
Remote repository
$ git remote add <repo_name> <url>
Local repo
Copy url name only
Remoterepo
Key points
Git clone :
– Creates a new repository by copying everything from an
existing repository.
Git remote add :
– Creates an entry with the name of a particular url in git
config file.
Pushing changes
$ git push <repo_name> <branch_name>
Local repo
Stagingarea
Workingdirectory
Remote repo
Push changes
Pulling changes
$ git pull <repo_name> <branch_name>
Local repo
Stagingarea
Workingdirectory
Remote repo
Pull changes
Fetching changes
$ git fetch <repo_name> <branch_name>$ git rebase <repo_name>/<branch_name>
Local repo
Stagingarea
Workingdirectory
Remote repo
Fetch changes
Rebase
Key points
Git pull :
– Internally it is 'git fetch' + 'git merge'.
Git fetch :
– Gets all the changes but does not apply to working copy.
Git rebase :
– Changes the commit history to match remote repo and applies
changes to working copy.
There are two ways to integrate changes 'merge' and 'rebase'
respectively.
Create branch
$ git branch <branch_name>
Master
B1
You are here
Switch between branch
$ git checkout <branch_name>
Master
B1
You are here
B2
Merge branch
$ git merge <branch_name>
Master
B1 You are here
Tagging
$ git tag <commit hash key>
Master
Tagged a commit
Powered by
Prathamesh Nevagi
Recommended