Version Control Systems -- Git -- Part I
-
Upload
sergey-aganezov -
Category
Software
-
view
415 -
download
0
Transcript of Version Control Systems -- Git -- Part I
![Page 1: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/1.jpg)
Programming workshop
5:15 pmVersion Control Systems
Part I
![Page 2: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/2.jpg)
JetBrains student program
Pycharmjetbrains.com/pycharm
jetbrains.com/student
Intellij IDEA jetbrains.com/idea
PhpStormjetbrains.com/phpstorm
And the list goes on…
![Page 3: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/3.jpg)
PRO Git v2https://git-scm.com/book/en/v2
Graphical content in this demonstration in partial is taken from PRO Git v2 book.
![Page 4: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/4.jpg)
Version control
Version control is a system that records changes to a file or set of files over time so that you can recall
specific versions later.
![Page 5: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/5.jpg)
Version control
Version control is a system that records changes to a file or set of files over time so that you can recall
specific versions later.
![Page 6: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/6.jpg)
Dummy version control
copy files into another directory (perhaps a time-stamped directory, if they’re clever).
![Page 7: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/7.jpg)
Dummy version control
copy files into another directory (perhaps a time-stamped directory, if they’re clever).
It is easy to forget which directory you’re in and accidentally write to the wrong file or copy over files you don’t mean to.
![Page 8: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/8.jpg)
Local version control
![Page 9: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/9.jpg)
Centralized version control (CVCS)
![Page 10: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/10.jpg)
Centralized version control (CVCS)Usual suspects:• CVS• Subversion• Perforce
Advantages:• everyone knows to a certain degree what everyone else on the project is doing• administrators have fine-grained control over who can do what• it is far easier to administer a CVCS than it is to deal with local databases on every client
![Page 11: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/11.jpg)
Centralized version control (CVCS)Disadvantages:
• Single point of failure (If the main server goes down the developers can’t save versioned change)
• Remote commits are slow• Unsolicited changes might ruin the development
• Single point of failure (if the hard disk of the central databse becomes corrupted the entire history could be lost)
• No easy way to go from single-developer to multipl-developer state
![Page 12: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/12.jpg)
Distributed version control (DVCS)
![Page 13: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/13.jpg)
Distributed version control (DVCS)Usual suspects:• Git• Mercurial• Bazaar
Advantages:• Full history is available to everyone at all times• Extemely fast due to local nature of the majority of the operation• No access to remote server is required• Sharing can be done among any subset of developers, before making changes public• Branching and merging is SUPER easy
![Page 14: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/14.jpg)
Distributed version control (DVCS)Disadvantages:
• Large number of files that can not be easily compressed may be an issue• Very long project history may result in a rather long initial download
![Page 15: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/15.jpg)
GitDate of birth: 2005Creator: Linus Torvalds
Requirements:• Speed• Simple design• Strong support fo non-linear development (thoudands of paraller branches)• Fully distributed• Large projects support
![Page 16: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/16.jpg)
Git: snapshots, not differences
![Page 17: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/17.jpg)
Git: snapshots, not differences
![Page 18: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/18.jpg)
Git• Filesystem on steroids
![Page 19: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/19.jpg)
Git• Filesystem on steroids
•Almost every operation is local
![Page 20: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/20.jpg)
Git• Filesystem on steroids
•Almost every operation is local
• Integrity
•Only adding data throughout time
![Page 21: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/21.jpg)
Git: project structure
![Page 22: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/22.jpg)
Git: basic workflow1. Checkout a revision to work on from repository
2. Modify files in working directory
3.* Add modified files into the staging area as you go
4. Commit you staged files into the repository
![Page 23: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/23.jpg)
Git: files status lifecycle
![Page 24: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/24.jpg)
Git: files status lifecycle
>>> git add file_name
![Page 25: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/25.jpg)
Git: files status lifecycle
>>> git add file_name
![Page 26: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/26.jpg)
Git: files status lifecycle
>>> git rm file_name
![Page 27: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/27.jpg)
Git: files status lifecycle
>>> git commit>>> git commit –m “commit message”>>> git commit –F commit_file>>> git commit –a>>> git commit file_name1 file_name2
![Page 28: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/28.jpg)
Git: branch
![Page 29: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/29.jpg)
Git: branches
![Page 30: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/30.jpg)
Git: branches>>> git branch iss53>>> git checkout iss53
>>> git checkout -b iss53
do some work in iss53
![Page 31: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/31.jpg)
Git: branches
do some work in iss53
![Page 32: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/32.jpg)
Git: branches
do some work in iss53
>>> git checkout master>>> git checkout –b hotfix
do some work in hotfix
![Page 33: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/33.jpg)
Git: branches
merge master with hotfix
>>> git checkout master>>> git merge hotfix
![Page 34: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/34.jpg)
Git: branches
delete hotfix branch>>> git branch –d hotfix
>>> git checkout iss53do some work in iss53
![Page 35: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/35.jpg)
Git: branches
>>> git checkout master>>> git merge iss53
![Page 36: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/36.jpg)
Git: branches
![Page 37: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/37.jpg)
Git: collaborating
![Page 38: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/38.jpg)
Git: remotes
Adding a remote:
>>> git remote add github https://github.com/aganezov/vcs-sample.git
>>> git remote github
>>> git remote –vgithub https://github.com/aganezov/vcs-sample.git (fetch)github https://github.com/aganezov/vcs-sample.git (push)
![Page 39: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/39.jpg)
Git: remotes
Remote branches are references of states of branches on your remote repository.
You can think of them as local branches that you can not move. They are mvoed automatically due to network communication.
They take form of (remote)/(branch)
>>> git remote
![Page 40: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/40.jpg)
Git: remotes
![Page 41: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/41.jpg)
Git: remotes• >>> git push github master [--set-upstream]• >>> git push
• >>> git fetchupdates the (remote)/(branch) pointers for you repository
• >>> git pull>>> git fetch>>> git mergemerges remote tracked branch into current one
![Page 42: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/42.jpg)
Git: remotes
![Page 43: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/43.jpg)
Git: remotes
![Page 44: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/44.jpg)
Takeaways:• VCS can save you from really bad things• Version Control Systems are easy to use
• Git is easy to use• Every Git revision is the snapshot of the entire project state!• Git branch is a simple pointer to a revision• Git remote branch is another simple pointer
• You are where the HEAD is• Branching and merging is super easy
• Github / Bitbucket are good free Git remote server options
![Page 45: Version Control Systems -- Git -- Part I](https://reader036.fdocuments.net/reader036/viewer/2022062822/587a60851a28ab520b8b7767/html5/thumbnails/45.jpg)
Next JetBrains GWU meeting
“VCS – Git – Part II”
December 17, 5:00 – 7:00 pm SEH room 2000
Facebook https://www.facebook.com/groups/jetbrains.gwu/
Twitter https://twitter.com/JetBrains_GWU
Email [email protected]