Professional Documents
Culture Documents
1.01 01 - Introduction To Git
1.01 01 - Introduction To Git
“GIT”
• Build scripts
• Implementation notes
• Test cases
• Deployment scripts
• Data files
• Design documents
• Requirement definitions
• And more
VERSION CONTROL SYSTEMS
• A Version Control System (VCS) is a software system that helps
teams and individual developers manage change to the work
artifacts
Workspace
(holds what the developer
is currently working only)
Workspace Repository
(holds what the developer VCS (keep track of all work
artifacts, with a complete
is currently working only)
change history)
Workspace
(holds what the developer
is currently working only)
VERSION CONTROL SYSTEMS
• There are many open source and proprietary VCS’s currently
available, e.g., CVS, SVN, Mercurial, and Git
• They differ in terms of
• How the repository is structured
• Where it is kept
• The kinds of files that can be tracked
• Whether developers must “checkout” or “lock” a work artifact working on it
• When and how work artifacts are checked in
• How conflicts are resolved
GIT
• Git is an open-source distributed VCS, and perhaps currently the most
popular
• Git can track changes for any kind of file
• Workspaces hold a clone or replica of the full repository and a staging
area, as well as working files
Workspace
Repository Repository
init
Repository Repository
Working Staging Clone Clone Staging Working
Files Area clone Area Files
pull
merge
add
commit
push
NON-BARE VS. BARE REPOSITORIES
• Bare Repositories are used as central or shared repositories
• Developers cannot make changes directly in bare repositories
Non-Bare Repository Bare Repository
Working Staging Clone Clone Staging Working
Files Area Area Files
pull
merge
add
commit
push
git clone… à #CLEAN COPY
git add, git status, git commit, git push… à rejected
git pull … à CONFLICT
Fixing conflict … à edit the file and remove <<<<<<< HEAD … >>>>>>>
git add, git commit, git push… à #DONE
GITHUB
ADVANCED GIT OPERATIONS
• We’ll only use the following basic operations: init, clone, pull, merge,
add, commit, and push
• We will not cover
• Branch
• Tags
• Checkout
• Fetches
• Reset
• And other advanced operations, that may be needed to resolve conflicts
GIT SOFTWARE
• GitHub
• https://github.com/
• Popular Git Service Providers: • You may use any Git service
• GitHub provider, but I prefer GitHub
• Bitbucket
• GitLab
• CloudForge
• GitBucket
• RocketGit
• And more
GETTING STARTED WITH GITHUB
• Install git on computer(s)
• Visit
• https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
• Create your account using your personal email, if you don’t have one
• Visit https://education.github.com/
• Register for a free account (with your personal email, and then add your institutional email to your
account)
• Using the on-line interface, create a repository
• This does a “git init –bare <your repository>” , set up bare repository that you own and control
• Clone that repository to your own system (your computer)
• Open a terminal window
• Change directories to the parent directory that you want to hold the project’s repository
• Copy the HTTPS URL for your repository from the GitHub webpage
• In the terminal window, type: git clone <paste the URL>
• Start practicing other git commands
BEST PRACTICES FOR USING GIT
• Commit and push changes frequently, but not every written line
• Typically, commits should involve one or a small number of related
changes. But not every line of code.
• Don’t wait until you’re done with a project
• Don’t separate commits for unrelated changes
• Enter a meaningful and concise comment with each commit, that
will help you remember what the changes were for and why you
made them
WHY USE GIT IN A PROGRAMMING CLASS
Programming Paradigms…