a way to manage files and directories.
track changes over time.
recall previous versions.
source control is subset of VCS.
sharing on multiple computers
Types of vcs:
Local VCS
Centralized VCS
Distributed VCS
Features of git
commands in git
2. Why is Git Around?
Consider we are working on some project, there are fi, f2, f3 files in one folder and
we want them to save them after changes. This will fill our hard disk if we want to
keep each version of file.
Project.zip Projectfinal.zip Projectfinal1.zip Projectfinal2.zip
3. Version Control System(VCS)
a way to manage files and directories.
track changes over time.
recall previous versions.
source control is subset of VCS.
sharing on multiple computers
7. GIT
Created by Linus Torvalds, creator of Linux, in 2005
– Came out of Linux development community
– Designed to do version control on Linux kernel
Goals of Git:
- Speed
- Support for non-linear development (thousands of parallel branches)
- Fully distributed
- Able to handle large projects efficiently
8. Features of GIT
Snapshots, NOT differences
Nearly every operation is local.
Git has Integrity(checksum)
Storing data as snapshots of the project over time
10. Let’s Start with GIT
• Enter these lines (with appropriate changes):
git config --global user.name "John Smith“
git config --global user.email jsmith@seas.upenn.edu
11. The Three stage
architecture
You modify files in your working
tree.
You selectively stage just those
changes you want to be part of
your next commit, which
adds only those changes to the
staging area.
You do a commit, which takes the
files as they are in the staging area
and stores that snapshot
permanently to your Git directory
12. Create and fill a repository
cd to the project directory you want to use
• This creates the repository (a directory named .git)
• You seldom (if ever) need to look inside this directory
Type in git init
• Period means “this directory”
• This adds all your current files to the repository
Type in git add .
• You can use a different commit message, if you like
Type in git commit –m "Initial commit"
13. Clone a repository from elsewhere
git clone URL
git clone
https://github.com/ishant
k/DSA2020-1
Instead of getting just a
working copy, Git receives a
full copy of nearly all data that
the server has.
15. Working with your
own repository
A head is a reference to a commit
object
The “current head” is called HEAD
(all caps)
This results in a linear graph:
A B C … HEAD
16. Back tracking, Removing, Rename
Rolling back to last commit
$ git checkout HEAD [filename]
$ git diff
Skipping staging area
$ git commit –a –m “your message”
Remove File from Staging
$ git reset HEAD [filename]
Remove file in Git
$ git rm [filename]
Rename file in Git
$ git mv [current_filename] [changed_filename]
20. GITHUB
GitHub.com is a site for online storage of Git repositories.
– You can create a remote repo there and push code to it.
– Many open source projects use it, such as the Linux kernel.
– You can get free space for open source projects, or you can pay for private projects.
Question: Do I always have to use GitHub to use Git?
Answer: No! You can use Git locally for your own purposes. – Or you or someone
else could set up a server to share files. – Or you could share a repo with users on
the same file system, as long everyone has the needed file permissions).