Git provide Distributed version control. Who is the user? Anyone want to truck hi note. Review history log changes. View difference between two versions.
1. Git
• Created by Linus Torvalds
• April 2005
• Distributed version control system
• Open source and free software
• Faster, support all platform
• Safe guard against data corruption ….
3. Github
• Lunched 2008
• GitHub offers plans for both private repositories and free
accounts which are commonly used to host open-source
software projects. As of June 2018, GitHub reports having
over 28 million users and 57 million repositories (including
28 million public repositories.),
4. Distributed version control
• Different users (or teams of users) maintain their own
repositories, instead of working from a central repository
• Changes are stored as change sets.
• Git focus on change set encapsulating a change set as a
discrete unit and then those change sets can be exchange
between repository
• No single master repository, just many working copies
• Each with their own combination of change sets.
5. Who is the user?
• Anyone want to truck hi note
• Review history log changes
• View difference between two versions
• Retrieve old version
• Anyone need to share changes with the collaborators
• Anyone not afraid of command line tools
6. Install git
• Mac OS
• brew install git
• Ubuntu
• apt-get install git
• Fedora
• yum install git
• Windows
• https://git-scm.com/download/win
9. Git Architecture
• Three tree architecture
• Add command add file staging index
Repository
Staging Index
Working
Commit
Add file
Pull
10. what is staging index?
• I have 5 file , I wanted to add 2 file, then I put 2 file in
staging index and commit 2 file. Still 3 file is left, not added
yet, also not commit yet, those are available in my working
tree, they never added in staging index, or remote server.
They are waiting for another commit.
11. What is SHA?
• When we change, git generate a check-sum code,
checksum is an algorithm that generate number from data.
• Git generate checksum using SHA-1 hash algorithm. This
algorithms produce 40 digit hex number.
• Goal of checksum: data didn’t change
• checksum->HASH->SHA-1
12. Data integrity
• Git sure that you cannot change what you have committed
, when you have reset any data your checksum must be
changed.
15. HEAD
• Head point to specific commit to the repository
• If you add new commit pointer have to change to new commit.
• Head point to “tip” current branch of the repository…
• Not staging index or working directory
• Last stage of repository what I checked out.
• Head pointer is the place where we start record.
• Head is the last commit of the current branch
• Head always checked currently check-out branch
18. Git reset
• —soft
• Does not change staging index or working directory.
• It just move the pointer
• Keep code safe zone
• It move only pointer nothing else
• —mixed
• Change head pointer to specify commit
• Change staging index to patch repository
• Does not change working directory
• We don’t lost any data
• —hard
• Change staging index and working directory to match
• Any changes after this commit are completely deleted….
• Automatically garbage collection
19. Caution
• When you wanted to reset anything , copy last few
commits and pest int a text file.
20. .gitignore
• *.php
• *.dll
• .DS_Store
• log/*.log
• !index.php//dont ignore…..
• Ignore all file within directory directory/
• Comment lines begins with #
• Git does not truck empty directory
21. Compare
• Comparing the commit references , what actual stage of
all files in this repository at that point of time.
• It means what the changes over time…..
22. Branching
• Don’t causes lot of headaches
• Don’t take lot of processing power
• Easy to created also easy to deleted
• Try new ideas
• Isolate features
• Context switching
• Swap out with two sets of changes
• Clean branch(trucked file) before context switching
24. Merging
• Fast-forward
• Conflict occurred when two changes on the same linear set of line
• —no-ff
• forces git to commit any way, don't do fast forward, make a
commit message
• —ff-only
• do the fast forward if you can do fast forward, if you unable
then skip
26. Truck changes to master
ffffac0 acc0145
33affgg
Merged two branches
4356aca
ffffcbc 1224cd
gh-pages
master
5556aca
6734cd
27. Stash
• Stash is a place where we can store changes temporarily
file without commit.
• Its not part of repo, staging index, or workspace
• Stash is available all the time, within all branches
• Stash pull does not matter which branch you are…..
28. Remotes
• More powerful
• It can collaborate with other
• Distributed version control
• http://github.com
35. Non tracking branch
• Git push -u origin master // -u is used to make sure it is
tracking branch
• If we do not use -u then it does not track remote branch
• It does not keep any information that this is the branch
what we are working in future…..
36. Non tracking branch
➜ git_est git:(master) git branch non
➜ git_est git:(master) git push origin non
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/cmabdullah/Demo.git
* [new branch] non -> non
➜ git_est git:(master) cat .git/config
➜ git_est git:(master) cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/cmabdullah/Demo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
// does not exist branch non, I.e branch non is non tracking branch
➜ git_est git:(master)