Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Version Control with SVN & Git CSC/ECE 517, Fall 2012 Titus Barik & Ed Gehringer, with help from Gaurav.

Similar presentations


Presentation on theme: "Introduction to Version Control with SVN & Git CSC/ECE 517, Fall 2012 Titus Barik & Ed Gehringer, with help from Gaurav."— Presentation transcript:

1 Introduction to Version Control with SVN & Git CSC/ECE 517, Fall 2012 Titus Barik (tbarik@ncsu.edu)tbarik@ncsu.edu & Ed Gehringer, with help from Gaurav Tungatkar (gstungat@ncsu.edu)gstungat@ncsu.edu

2 Local version control: RCS Keep many copies of files Error prone RCS stores deltas Version 3 Version 2 Version 1 File check out

3 Centralized Version Control If you need to work with other programmers … Version 3 Version 2 Version 1 File check out File check out Computer B Computer A

4 File Server vs. Version-Control Server At first glance, the client- server architecture of a version-control system looks much like a typical file server. So why do we need version control?why do we need version control

5 File Sharing Issues, 1 Assume your project has 15 developers: –Each developer wants to make 1 change and must communicate this change to all other developers. –What are the total number of interactions that must occur? C(15, 2) = N(N – 1)/2 = 15(14)/2 = 105. That’s a lot of information to track!

6 File Sharing Issues, 2 Image: Version Control with Subversion The problem is that users are stepping on each other’s feet!

7 Approach 1: Lock, Modify, Unlock Image: Version Control with Subversion 1.Locking may cause administrative problems. 2.Locking may cause unnecessary serialization. 3.Locking may create a false sense of security.

8 Approach 2: Copy - Modify-Merge Image: Version Control with Subversion Sounds chaotic, but in practice, runs extremely smoothly. Question: When is locking necessary?

9 Subversion (SVN) Open source, Apache License. Available on all major operating systems. Improvements such as “cheap” copying and branching, remote options (https), over legacy CVS. However, CVS has more mature tools, and SVN has it own flaws (DVCS).

10 Answer these questionsAnswer Give one advantage of using a version-control server for source-code management over using a fileserver. Suppose a project has 15 developers and no shared repository. Can you come up with a better way of communicating changes than N(N-1)/2 interactions? Explain how locking can cause administrative problems. Explain how locking can create a false sense of security. With copy- modify-merge, when is locking necessary? Exercise 1

11 Branches and Tags Trunk: Location where main development occurs. Branches: Location used to isolate changes to another development line (e.g., experimental features). Tags: Snapshot of the content (e.g., RTM, service packs, EOL). Image: http://en.wikipedia.org/wiki/Subversion_(software)

12 Populated Repository Image: Version Control with Subversion A Subversion repository layout. The folder names are just a convention, and have no special meaning to the repository.

13 Creating a Branch Image: Version Control with Subversion In Subversion, the underlying mechanism of a branch is implemented by performing a simple directory copy.

14 Exercise 2 Answer these questions about branches.Answer oSuppose, in fixing a bug, you modify three lines of code in two source files. Should you create a new branch? Why or why not? oWhich would probably be more common, branches or tags? oWhat are some of the risks of copying files in a repository? How do version-control systems minimize this risk?

15 Distributed Version Control Clients don’t check out individual files; they mirror the repository. What’s the advantage? Version 3 Version 2 Version 1 Version 3 Version 2 Version 1 Version 3 Version 2 Version 1 File Computer AComputer B

16 Git Came out of the Linux project, in 2005. 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)

17 Integrity & Checksums Everything checksummed with an SHA-1 hash –40-character string –composed of hex characters –calculated based on the contents of a file or directory structure in Git Example –24b9da6552252987aa493b52f8696cd6d3b00373 Git knows everything by hash, not filename

18 Snapshots, not Diffs See http://progit.org/book/ch1-3.htmlhttp://progit.org/book/ch1-3.html Every time you commit, Git takes a snapshot of your files. Files that have not changed are not copied.   Almost all ops are local browse history commit

19 3 States of a File in Git Modified Staged Committed working directory staging area git directory (repository) check out the project stage files commit

20 File Status Lifecycle unmodifiedmodifiedstaged edit the file stage the file untracked add the file remove the file

21 Checking Status To check the status of your files: $ git status # On branch master nothing to commit (working directory clean) Creating new files $ vim README $ git status # On branch master # Untracked files: # (use "git add..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track)

22 Checking status, cont. Begin to track the file: $ git add README The file is now tracked: $ git status # On branch master # Changes to be committed: # (use "git reset HEAD..." to unstage) # # new file: README # For more info: http://progit.org/book/ch2-2.html http://progit.org/book/ch2-2.html

23 Remotes On a project, you may be working with several remote directories. “Origin” is the server you cloned your repository from $ git clone git://github.com/schacon/ticgit.git Initialized empty Git repository in /private/tmp/ticgit/.git/ remote: Counting objects: 595, done. remote: Compressing objects: 100% (269/269), done. remote: Total 595 (delta 255), reused 589 (delta 253) Receiving objects: 100% (595/595), 73.31 KiB, done. Resolving deltas: 100% (255/255), done. $ cd ticgit $ git remote origin http://progit.org/book/ch2-5.html

24 Pulling, pushing to remote $ git fetch [remote-name] E.g., git fetch origin git push origin master

25 Common Workflow using Git Centralized workflow … http://progit.org/book/ch5-1.html Integration-manager workflow … Common use cases: http://progit.org/book/ch5-2.html http://progit.org/book/ch5-2.html

26 Exercise 3 Answer these question about DVCSs.Answer oWhat is an advantage of referring to files and branches by hash, rather than by filename? oCan you think of one disadvantage of a DVCS compared to a centralized VCS?


Download ppt "Introduction to Version Control with SVN & Git CSC/ECE 517, Fall 2012 Titus Barik & Ed Gehringer, with help from Gaurav."

Similar presentations


Ads by Google