Download presentation
Presentation is loading. Please wait.
Published byCarol Wilson Modified over 9 years ago
1
علیرضا فراهانی استاد درس: جعفری نژاد مهر 1393
2
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. ▪Why? –Revert files back to a previous state –Compare changes over time –see who last modified something –Generally, if you screw things up or lose files, you can easily recover
3
Local, Centralized, Distributed ▪Local: –Storing backup versions in hard drive (Perhaps a time- stamped directory) ▪Centralized: –need to collaborate with developers on other systems –single server that contains all the versioned files, and a number of clients that check out files from that central place –CVS, Subversion, and Perforce
4
CVCS (Pros & Cons) ▪Pros –Access level (admin, write, read) –Knowing what others are doing ▪Cons –Single point of failure
5
Local, Centralized, Distributed ▪Distributed –Every client has whole repository with its history –Git, Mercurial, Bazaar
6
DVCS (Pros & Cons) ▪Pros –Fast –Even with server being down, every client can continue to work and save its code changes. ▪Cons –Greater redundancy
7
Git Vs SVN
8
A short history of Git
9
▪Linux kernel development ▪1991-2002 –Changes passed around as archived file ▪2002-2005 –Using a DVCS called BitKeeper ▪2005 –Relationship broke down between two comunity
10
A short history of Git ▪Goals –Speed – Simple design – Strong support for non-linear development (thousands of parallel branches) – Fully distributed – Able to handle large projects like the Linux kernel efficiently (speed and data size)
11
A short history of Git ▪Popularity –Git is now the most widely used source code management tool –33.3% of professional software developers use Git or GitHub as their primary source control system
12
Git Basics ▪Snapshots, not changes –a picture of what all your files look like at that moment –If a file has not changed, store a reference ▪Nearly Every Operation Is Local –Browsing the history of project –See changes between two versions
13
Git Basics (Cont.)
14
▪Git has Integrity –Everything is check-summed before it is stored and is then referred to by that checksum –40-character string (e.g. 24b9da6552252987aa493b52f8696cd6d3b00373) –Git stores everything not by file name but in the Git database addressable by the hash value of its contents ▪Git Generally Only Adds Data –very difficult to get the system to do anything that is not undoable or to make it erase data in any way
15
Git Basics (Cont.) ▪The Three States –Modified ▪File has changed but not committed –Staged ▪Marked to go to next commit snapshot –Committed ▪Safely stored in local database –Untracked! ▪Newly added or removed files
16
Git Basics (Cont.) ▪Three Main Section of a Git Project –Working Directory ▪Single checkout of one version of the project. –Staging Area ▪Simple file storing information about what will go into your next commit –Git Directory ▪What is copied when cloning a repository
17
Git Basics (Cont.) ▪Three Main Section of a Git Project
18
Git Setup ▪Installation –You’ve done it already! ▪Your identity –$ git config --global user.name "John Doe" –$ git config --global user.email johndoe@example.comjohndoe@example.com ▪Github distinguish you account from others by this data ▪Getting help –$ git help –$ git --helpe.g. git help commit –$ man git-
19
Authenticating with git servers ▪Https –You’ll be asked for your git server username and password with each remote command (pull, push,..) ▪SSH –Generate new SSH key –Add SSH key to Git server
20
Using Git ▪Initializing new repository –git init ▪Staging untracked files –Git add ▪Git add README.md ▪Git add. ▪Git add src/ ▪Git add *.java
21
Using Git (Cont.) ▪Clone a repo –git clone ▪git clone git://github.com/schacon/grit.git ▪git clone ssh://github.com/schacon/grit.git ▪Checking the Status of Your Files –git status
22
Using Git (Cont.) –Git status ▪Shows which files are in which state ▪git status –s (shorter version) ▪A file can in staged and modified state at the same time
23
Using Git (Cont.) ▪Ignoring files –Class of files that you don’t want Git to automatically add or even show –Log files, generated files –Solution?. gitignore
24
.Gitignore file ▪A specific file –My.txt ▪Ignore by file name –*.[oa](all files with either.o or.a extension) –*~(temporary files) ▪Excluding a file from extension pattern –!lib.a(do track the lib.a file) ▪Ignore by folder –gen/
25
Using Git (Cont.) ▪Committing your changes –must provide a message –git commit ▪git commit(launches your editor of choice) –git config --global core.editor –git commit –m ▪inline message with commit command ▪$ git commit –m “job’s done” –-a ▪automatically stage files already tracked before ▪git commit –am “main activity finished”
26
Using Git (Cont.) ▪Removing files –git rm ▪removes file(s) from staging area and working directory –--cached ▪keep file on disk but not have Git track in anymore ▪removing accidentally added files ▪$ git rm log/\*.log –all files ending in “.log” which are in “log” folder
27
Using Git (Cont.) ▪Viewing commit history –log command ▪$ git log ▪$ git log -2 –limits number of commits shown
28
Using Git (Cont.) ▪Undoing things –Unmodifying a Modified File ▪git checkout -- (to last committed version) –Unstaging a Staged File ▪git reset HEAD –Reset the staging area and the working directory to match the target commit ▪Git reset –hard (deletes history) –Rolling back to a commit making it the head ▪Git revert
29
Git branches
30
Using Git (Cont.) ▪Working with remotes –Pushing to Your Remotes ▪push command –$ git push origin (e.g. master) –pulling from your remote ▪pull command –pull is fetch and then a merge –$ git pull origin –fetch and merge is better
31
Useful links ▪Undoing things –atlassian.com/git/tutorials/undoing-changes/git-resetatlassian.com/git/tutorials/undoing-changes/git-reset ▪git GUIs –stackoverflow.com/questions/315911/git-for- beginners-the-definitive-practical-guidestackoverflow.com/questions/315911/git-for- beginners-the-definitive-practical-guide ▪step by step guide –try.github.comtry.github.com
32
Useful links مدلسازي موضوعپيادهسازينتايججمعبندي
33
با سپاس فراوان مدلسازي موضوعپيادهسازينتايججمعبندي
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.