Beruflich Dokumente
Kultur Dokumente
Week 4
Earliest tools were around 1972 (SCCS) Older tools RCS, CVS, Microsoft Source Safe, PVCS Version Manager, etc Current tools Subversion, Mercurial, Git, Bazaar
Introduction To GIT
Terminologies
Backporting
Action of taking a certain software modification(patch) and applying it to an older version of the software than it was initially created for.
Repository
A data structure usually stored on a server that contains:
A set of files and directories. Historical record of changes in the repository. A set of commit objects. A set of references to commit objects, called heads.
Working Copy
A local copy of files from a repository, at a specific time or revision.
Terminologies contd
Commit
An action of writing or merging the changes made in the working copy back to the repository.
Check-out
The act of creating a local working copy from the repository. A user may specify a specific revision or obtain the latest.
Examples
CVS(Concurrent Versioning System) SVN(Subversion) Visual Source Safe
Challenges
Multi-developer conflicts Client/server communication
Git Advantages
Resilience
No one repository has more data than any other
Speed
Very fast operations compared to other VCS (Im looking at you CVS and Subversion)
Space
Compression can be done across repository not just per file Minimizes local size as well as push/pull data transfers
Simplicity
Object model is very simple
Git Architecture
Index
Stores information about current working directory and changes made to it.
Object Database
Blobs (files)
Stored in .git/objects. Indexed by unique hash. All files are stored as blobs.
Tags
Reference to another object and can hold additional meta-data related to another object.
HEAD
Refers exclusively to the currently active head. This distinction is used frequently in Git documentation.
Detached HEAD
A git repository is a tree-of-commits, with each commit pointing to its ancestor(s). If a commit hash which isn't pointed to by a tag or a branch is checked out, you get a detached head. How to resolve this issue?
Create a new branch to retain commits you create. $ git checkout -b new_branch_name
Branch
Branch and Head are nearly synonymous. Every Branch is represented by one Head, and every Head represents one Branch. Sometimes, Branch will be used to refer to a head and the entire history of ancestor commits preceding that head.
Head
Head will be used to refer exclusively to a single commit object, the most recent commit in the branch. A head(lowercase) refers to any one of the named heads (master, stable, dust) in the repository.
HEAD
Refers exclusively to the currently active head. This distinction is used frequently in Git documentation.
Some Commands
Getting a Repository
git init git clone
Getting information
git help git status git diff git log git show
Commits
git add git commit
.gitignore
Stored in directory for ignoring
$ git status
Shows list of modified files
Branching
Git branching is lightweight
No massive copying a la CVS/Subversion Tools for helping merge branches and changes easily
You are ALWAYS on a branch Branches can be local or remote Key commands
git branch git merge git cherry-pick
Allows you to choose specific commits to apply You can edit the commits while cherry picking
Using Branches
git checkout -b branch git checkout -b devel/branch git branch
Lists all local branches available
We can now make changes in one branch and propagate change using
git merge git cherry-pick
n: newest n commits
git reset
Moves the tree back to a certain specified version Use the --force to ignore working changes
git revert
Reverts a commit Does not delete the commit object, just applies a patch Reverts can themselves be reverted!
Rebasing Example
Simple branching o--o--o <-- origin \ a--b--c <-- mywork
Rebasing Example
Work done on origin branch o--o--O--o--o--o <-- origin \ a--b--c <-- mywork
Rebasing Example
Could merge changes into branch git merge origin o--o--O--o--o--o <-- origin \ \ a--b--c--m<-- mywork
Rebasing Example
Rebasing moves branch point git rebase origin o--o--O--o--o--o <-- origin \ a`--b`--c`
Cleaning Up
git clean
Cleaning up untracked files.
git fsck
Checks object database to make sure all is sane Can show information about dangling objects
git gc
Cleans up repository and compress files When used with --prune, cleans out dangling blobs Can really speed up larger repositories
SEASnet
Git is in /usr/local/cs/bin. $ bash $ vim(emacs) .bashrc Add the following lines PATH=$PATH:/usr/local/cs/bin export PATH Save and quit. $ source .bashrc
Your default shell should be bash in order to use .bashrc. Whenever you login run $ source .bashrc.
Getting Started
$ mkdir gitroot $ cd gitroot $ git clone git://git.savannah.gnu.org/diffutils.git
Getting a Copy of the Git Repository
$ git tag
Copy and paste to git-tags.txt.
Apply patch
$ patch < quote-patch.txt
Only the files that are in the current working directory(~/gitroot/diffutils/) are patched. If the patch command outputs error message, hit Enter key twice. You have to change the directory to apply all the patch content.
$ cd man, $ cd src, $ cd doc, $ cd tests, and so forth.
$ cd man $ patch < ../quote-patch.txt (since the patch file is in the upper directory) Apply the patch for all the files.
Instructions
Check out version 3.0 of diffutils from your repository, into a new branch named quote.
Use git branch.
Install your change into this new branch, by running the patch command with your patch quote-3.0-patch.txt as input.
Use patch command.
Create an appropriate entry in the ChangeLog file for your patch, by adapting the change log from the original patch.
Edit the Changelog file.
Instructions contd
Commit your changes to the new branch.
Use git commit.
Use the command git format-patch to generate a file formatted-patch.txt. This patch should work without having to fix things by hand afterwards.
Use git format-patch.
Verify that this patch works, by checking out version 3.0 again into a new temporary branch tmp, applying the patch with the command git am, and building the resulting system, checking that it works with make check.