Git Version Control System
-
Upload
s-m-masoud-sadrnezhaad -
Category
Software
-
view
415 -
download
3
Transcript of Git Version Control System
![Page 1: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/1.jpg)
سامانه کنترل ورژن گیت
برنامه نویسی پیشرفته به زبان جاوا – دانشگاه صنعتی شریف
۱۳۹۵ اردیبهشت ۱سیدمحمدمسعود صدرنژاد –
![Page 2: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/2.jpg)
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
2
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
فهرست مطالب
. دلیل استفاده از ورژن کنترل و انواع آن۱
نحوه کار کردن ورژن کنترل. ۲
۳. Stage و Branch و Merge و Rebase
. آموزش کارگاهی استفاده از ورژن کنترل۴
![Page 3: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/3.jpg)
3
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
What is version control?
...a system that lets you trackchanges in your source codeby “checking in” your code
into the system.
![Page 4: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/4.jpg)
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
4
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
امکاناتی که ورژن کنترل در اختیار می گذارد
ثبت تغییرات در طول زمان
انجام آزمایش بدون تأثیر گذاشتن روی برنامه در حال اجرا
امکان مدیریت و انجام پروژه ها به صورت گروهی
(... کامنت، برنچ و) و کارهای دیگر در ارتباط با سورس کد
![Page 5: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/5.jpg)
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
5
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
چرا باید از ورژن کنترل استفاده کنیم
نگه داری سابقه و دنبال کردن تغییرات
بازگشت سریع به کد پایدار و قابل اجرا
مشارکت آسان تر
بک آپ های آسانتر
Sandboxing
![Page 6: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/6.jpg)
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
6
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
انواع سامانه های کنترل ورژن
) متمرکزCenteralized(
) توزیع شدهDistributed(
![Page 7: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/7.jpg)
7
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Centeralized
![Page 8: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/8.jpg)
8
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Centeralized
![Page 9: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/9.jpg)
9
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Centeralized
![Page 10: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/10.jpg)
10
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Distributed
![Page 11: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/11.jpg)
11
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Distributed
![Page 12: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/12.jpg)
12
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Distributed
![Page 13: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/13.jpg)
13
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Available Version Control Systems
Centralized VCS
CVSSubversion (SVN)Team Foundation Server (TFS)
Distributed VCS
GitMercurial (hg)Bazaar
![Page 14: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/14.jpg)
14
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Online VCS Hosting
Github
Bitbucket
Gitlab
Codeplex
![Page 15: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/15.jpg)
15
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 16: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/16.jpg)
16
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 17: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/17.jpg)
17
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 18: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/18.jpg)
18
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 19: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/19.jpg)
19
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 20: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/20.jpg)
20
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 21: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/21.jpg)
21
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 22: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/22.jpg)
22
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 23: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/23.jpg)
23
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
How They Work
![Page 24: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/24.jpg)
24
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
What is Git
...a distributed version control systemcreated by Linus Torvalds, creator of Linux
to replace BitKeeper as the VCS usedfor maintaining the Linux kernel.
![Page 25: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/25.jpg)
25
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Design Goals for Git
Speed
Simplicity
Strong support for non-linear development
Ability to handle large projects
![Page 26: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/26.jpg)
26
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
What Makes Git Different?
Snapshots, Not Differences
![Page 27: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/27.jpg)
27
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
What Makes Git Different?
![Page 28: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/28.jpg)
28
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
What Makes Git Different?
It's All (Mostly) Local
![Page 29: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/29.jpg)
29
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Three Main Stages
Commited
Staged
Modifed
![Page 30: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/30.jpg)
30
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Installing Git
http://git-scm.com/book/en/Getting-Started-Installing-Git
![Page 31: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/31.jpg)
31
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
Git commits are pointers to the
previous commit
![Page 32: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/32.jpg)
32
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 33: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/33.jpg)
33
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 34: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/34.jpg)
34
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 35: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/35.jpg)
35
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 36: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/36.jpg)
36
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 37: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/37.jpg)
37
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 38: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/38.jpg)
38
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 39: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/39.jpg)
39
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 40: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/40.jpg)
40
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merging
![Page 41: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/41.jpg)
41
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merging
![Page 42: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/42.jpg)
42
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merging
![Page 43: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/43.jpg)
43
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merging
![Page 44: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/44.jpg)
44
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merging
![Page 45: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/45.jpg)
45
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merging
![Page 46: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/46.jpg)
46
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merging
![Page 47: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/47.jpg)
47
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 48: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/48.jpg)
48
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 49: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/49.jpg)
49
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
![Page 50: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/50.jpg)
50
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches
Long Running Branches Stick Around
Topic Branches Center Around Features,Bug Fixes, Etc
Merged Back Into a Long Running Branch
Topic Branches Are Usually DeletedWhen You're Done With Them
![Page 51: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/51.jpg)
51
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Deleting a Branch
git branch D BRANCHNAME
![Page 52: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/52.jpg)
52
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Deleting a Branch
git branch D testing
![Page 53: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/53.jpg)
53
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Remote Branches
git push REMOTE BRANCHNAME
![Page 54: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/54.jpg)
54
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Deleting Remote Branches
git push REMOTE :BRANCHNAME
![Page 55: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/55.jpg)
55
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Deleting Remote Branches
git push origin :testing
![Page 56: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/56.jpg)
56
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches (Review)
![Page 57: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/57.jpg)
57
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches (Review)
![Page 58: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/58.jpg)
58
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches (Review)
![Page 59: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/59.jpg)
59
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches (Review)
![Page 60: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/60.jpg)
60
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Branches (Review)
![Page 61: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/61.jpg)
61
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Rebase
![Page 62: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/62.jpg)
62
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Rebase
![Page 63: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/63.jpg)
63
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merged Without Rebase
![Page 64: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/64.jpg)
64
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Merged With Rebase
![Page 65: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/65.jpg)
65
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Rebase
Never Rebase a Public Branch!
![Page 66: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/66.jpg)
66
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
Workshop
Let's See in Action
Open Your Terminal
![Page 67: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/67.jpg)
Initiate Git and It's FilesWorking With Changes
![Page 68: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/68.jpg)
# make a new directory and go to project path
> mkdir git_repo
> cd git_repo
# initialize git
> git init
Initialized empty Git repository in /path/to/git/repository/.git/
> ls -a
. .. .git
# let's have a deeper look at .git directory
> ls -a .git/
. .. branches config description HEAD hooks info objects refs
![Page 69: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/69.jpg)
# define your name and email address (this config is per machine)
> git config --global user.name "Masoud Sadrnezhaad"
> git config --global user.email [email protected]
# checkout your git config
> git config --list
user.name=Masoud Sadrnezhaad
credential.helper=cache
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
![Page 70: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/70.jpg)
# create and open README.md file with your default system editor.> vi README.md
# let's write a readme file (with or witout markdown syntax)
# go to insert mode by click "I" one time# and go back to command mode by Esc. save the file by "wq"
# make sure everything ok.> ls -a. .. .git README.md
# check modification and it's level (slide 62) you see modifications at first level.> git statusnothing added to commit but untracked files present (use "git add" to track)
![Page 71: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/71.jpg)
# level up this file to staged level> git add README.md
# look at git status. you see changes in staged level.> git status
# add staged changes to new commit.# write a meaningful message for your commit.> git commit -m "added readme file"[master (root-commit) 021bd57] commit message 0 files changed create mode 100644 README
# look at git status. there is nothing to commit because changes# are commited.> git status
![Page 72: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/72.jpg)
# let's take a look at created commits.
> git log
commit 021bd57955b472d8e6979ba71e4907e9f1e3ab8b
Author: Masoud Sadrnezhaad <[email protected]>
Date: Fri May 1 02:12:46 2015 +0430
commti message
# final notes:
# it's easier to add and commit at once.
> git commit -am "commit message"
# this command add All files in your project directory
> git add -A
![Page 73: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/73.jpg)
Undoing Things
![Page 74: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/74.jpg)
# adding new modification to previous commits.
> git commit --amend
# you see commit message as it's name in first line.# uncomment changes you want to ammend to that commit# then save the file and close the editor.
# you see this modification in your last commit> git log
![Page 75: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/75.jpg)
# do some modification and stage them.
# now imagine that you want to unstage one of added files.# to undo "git add"
> git reset HEAD README.md
# undo to last working version of that specific file.> git checkout -- README.md
# undo to last working commit.# actually this one reset everything not only one file.
> git reset --hard
HEAD is now at 11d075a commit message
![Page 76: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/76.jpg)
Branching
![Page 77: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/77.jpg)
# see list of all availeble branches.> git branch* master
# asterix indicates that HEAD is pointing to master branch.
# let's create a new branch and name it dev> git branch dev
# HEAD is pointing to last commit of master branch likewise before.> git branch dev* master
# change HEAD pointer to dev branch.> git checkout devSwitched to branch 'dev'
![Page 78: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/78.jpg)
# do some modification and commit them.
> git commit -am "message"[master 79635ac] message 1 file changed, 1 insertion(+)
# switch back to master branch.> git checkout devSwitched to branch 'dev'
# open recent changed files. changes does not apply becuz# you are working on master branch and commited to dev branch.
# it's possible to create and switch to new branch at once.> git checkout -b dev master# master indicates that new branch is started from master.# -b used to create it.
![Page 79: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/79.jpg)
# to merge branch dev switch to branch you are going to merge with
> git checkout master
# now merge dev. this remove dev branch automatically# but it keeps revision history (changelog)
> git merge dev
![Page 80: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/80.jpg)
Remotes
![Page 81: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/81.jpg)
# use .gitignore to indicate which files are not going to pushed
# into remote repository. you can put it everywhere in your project
# we use ! to exclude some files and dirs and * for all of them.
# use this command when you want to have a local copy
# from remote repository. --bare is used
> git clone --bare ~/git-repo/
# to clone from github
> git clone [email protected]:smmsadrnezh/repo-name.git
# to see centeral repository url you fetch from or push into
> git remote -v
origin https://github.com/smmsadrnezh/repo-name.git (fetch)
origin https://github.com/smmsadrnezh/repo-name.git (push)
![Page 82: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/82.jpg)
# to push commits> git push -u origin master
# typing "-u origin master" is only needed at first time.
# to get commits pushed by other collaborators.# pull is equivalent to run fetch and merge one by one.> git pull
# fetch get's commits but do'nt merge it.# use diff command to see differences.> git fetch origin> git diff origin/master
# important note: pull everytime you want to push# merge conflicts when using three way merge
![Page 83: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/83.jpg)
Rebase
![Page 84: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/84.jpg)
# rebasing branches is not a good idea
> git branch> gitx> git rebase master
![Page 85: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/85.jpg)
برنامه نویسی پیشرفته به زبان جاوا ۱۳۹۵/۲/۱
67
کارگاه سامانه کنترل ورژن گیتسیدمحمدمسعود صدرنژاد
منابع
تصاویر ازMichael Kobyhttps://mkoby.com
![Page 86: Git Version Control System](https://reader034.fdocuments.net/reader034/viewer/2022052405/587aea821a28ab7f378b5299/html5/thumbnails/86.jpg)
پرسش و پاسخپرسش و پاسخ
طراحی شده به وسیله
sadrnezhaad.ir/smmsadrnezhaad.ir/smm
سیدمحمدمسعود صدرنژاد