Version Control History and Git Basics
-
Upload
sreedath-n-s -
Category
Technology
-
view
282 -
download
0
Transcript of Version Control History and Git Basics
● Management of changes to collection of Information● Identified by revision number● Revisions can be compared restored and merged● Coordinating Teams
Version Control Software
● One true source code● Commit and Checkout from a central location● No need to keep many copies of single file in hard disk● Eg:- SVN, OpenCVS and Perforce● Difference in workflow and performance● Typical CVCS Workflow
○ Pull down any changes other people have made from the central server
○ Make your changes, and make sure they work properly○ Commit your changes to the central server, so other programmers
can see them
Centralised VCSs
● Every repository is good as any other● Do not necessarily rely on a central server● Developer “clones” a copy of a repository and has the full history of the
project on their own hard drive● “Pulling” and “Pushing”● Act of cloning
Distributed VCSs
● Actions other than pushing and pulling to repositories are extremely fast● Committing new changesets can be done locally● Work and commit changes from anywhere without Internet, push them
all to git server at once● Share with one or two people to get feedback and then share with all
Advantages of DVCS
● Space needed to store all version of large binary files can accumulate quickly
● Long history projects can take an impractical amount of time and disk space
Disadvantages of DVCS
● Centralized VCS○ List of file based changes
● Distributed VCS○ Set of snapshots of a miniature filesystem
Data Storage in a repository
● Distributed revision control system● Designed and developed by Linus Torvalds● A Git working repository is a fully-fledged repository● Distributed under GNU General Public License version 2
Git
● Development began in April 2005● BitKeeper - A proprietary source control management system● Necessity of an distributed open source SCM● Other design Criterias
○ Take Concurrent Versions System (CVS) as an example of what not to do; if in doubt, make the exact opposite decision
○ Support a distributed, BitKeeper-like workflow○ Very strong safeguards against corruption, either accidental or
malicious● “The unpleasant person”
Evolution of Git
● Command-line method○ git init○ git init <reponame>○ git --bare init
Make your first git repository
● SVN Checkout and Git Clone● SVN Update and Git Pull● SVN Commit and Git commit & push
Confusions of a Subversion user
● Tell Git who you are○ git config --global user.name "Sam Smith"○ git config --global user.email [email protected]
● Create a new local repository○ git init
● Checkout a repository○ git clone /path/to/repository○ git clone username@host:/path/to/repository
● Add files○ git add <filename>○ git add .
Git common commands
● Commit○ git commit -m “commit message”○ git commit -a
● Push○ git push origin master
● Status○ git status
● Connect to a remote repository○ git remote add origin <server>○ git remote -v
Git common commands (Contd.)
● Branches○ git checkout -b <branchname>○ git checkout <branchname>○ git branch○ git branch -d <branchname>○ git push origin <branchname>○ git push --all origin○ git push origin :<branchname>
Git common commands (Contd.)
● Update from the remote repository○ git pull○ git merge <branchname>○ git diff○ git diff --base <filename>○ git diff <sourcebranch> <targetbranch>○ git add <filename>
● Tags○ git tag 1.0.0 <commitID>○ git log○ git push --tags origin
Git common commands (Contd.)
● Undo local changes○ git checkout -- <filename>○ git fetch origin○ git reset --hard origin/master
● Search○ git grep "foo()"
Git common commands (Contd.)
● Inspecting history
● Committing local changes○ Inspect your local changes
Git for subversion users (Contd.)
● Committing local changes○ add/remove changed files
○ commit your changes
Git for subversion users (Contd.)