CS174
Chris Pollett
Oct. 2, 2013
svnadmin create /path_to_repository svn co repository_uri local_dir ; cd local_dir #svn import trunk file:///path_to_files_want_in_initial_repository #if importing from a different repository svn mkdir trunk #don't do if did above svn mkdir branches svn mkdir tags
svn checkout url_or_path_to_repository local_dir Or svn co url_or_path_to_repository local_dir
svn list
svn update or svn up
svn resolved filename_with_conflict.
svn ci -m "Fixes BugXXXX, r=so-and-so, a=someone-else"so-and-so is the person who reviewed the patch, someone-else is the person who approved the check-in. You often only have r= or a= but not both.
svn add filename
svn delete filename
svn diff > my_patch.txt
patch -p0 < my_patch.txt
svn copy trunk_url prod_url -m "Create production tag"
svn merge -r###:HEAD trunk_url branch_namethen commit the result.
svn merge -r###:HEAD branch_url trunkon the local copy, then commit the result.
git init name_of_git_repository.
git clone path_to_clone_from to_folder #from scratch case git pull path_to_from_repos branch_name_you_want_to_pull_into #existing case git checkout branch #makes branch the current branch in the repository you are working on
mkdir myrepos cd myrepos git init git add . echo "hi there" > test.txt git add test.txt git commit -a -m "Initial commit" cd .. git clone file:///Users/cpollett/myrepos myrepos2 cd myrepos2 # now start editing myrepos2 echo "test2" > test2.txt git add test2.txt git commit -a -m "Made some changes" cd ../myrepos #now want to get changes back in myrepos git pull file:///Users/cpollett/myrepos2 masterThis produces a copy of the repository in a separate folder. We then edit the copy, and pull the changes back (the changes were in the clone's master branch) into the original repository. We will describe git add and git commit in a moment.
git pullas git will default to pulling where it was cloned from.
<Location /git/myrepos.git> DAV on AuthType Basic AuthName "My site" AuthUserFile /etc/apache2/myrepos.passwd <LimitExcept GET HEAD PROPFIND OPTIONS REPORT > Require valid-user </LimitExcept> </Location>
mkdir myrepos.git cd myrepos.git git init --bare git update-server-info
sudo chown -R _www . sudo chgrp -R _www .
sudo httpd -k stop sudo httpd -k start
git config -l #lists current config settings. git config setting_name new_value #changes a setting
git config --global user.name "Your Name Comes Here" git config --global user.email you@yourdomain.example.com
git config remote.upload.url http://myserver/git/myrepos.git
cd myrepos git init git add . git commit -m "setting up initial repository" git push upload masterThis might ask for password info. If you like you can configure a ~/.netrc file to save this info. This is a file on *nix systems with the following lines:
machine [servername] login [username] password [password]where you replace what's in brackets with the relevant info.
git add file_or_folder #folders added recursively, #.gitignore can be used to list files you don't want added or managed. git clean #gets rid of files git doesn't know about git rm file #removes the file from the repository, with -f deletes from filesystem git mv loc1 loc2 #moves file from loc1 to loc2 git checkout [rev] file #gets the [rev] version of the file into the current branch #-f overwrites uncommitted changes.
git commit -m "Commit message" git commit -a -m "Commit message" #the -a adds any unmanaged files to the repository
git reset --hard HEAD
git branch
%git pull Auto-merging tmp.php CONFLICT (add/add): Merge conflict in tmp.php Automatic merge failed; fix conflicts and then commit the result. %cat tmp.php cat tmp.php <?php <<<<<<< HEAD echo "hello"; echo "good bye"; ======= >>>>>>> a9a8ed990108598d06334e29c0eb37d98f0845aa ?>Here % is the command prompt.
git add tmp.php git commit -m "conflicts fixed and here is a message saying how"
git format-patch rev1 rev2
git format-patch e3e4f2067 --stdout > my.patchHere no rev2 is given so it will be assumed to be HEAD.
% git apply --stat my.patch test1.php | 2 ++ test2.php | 2 ++ test1.php | 1 + test2.php | 2 -- 4 files changed, 5 insertions(+), 2 deletions(-)
git apply --check my.patch
git am --signoff < my.patch
git tag -a tag_name revision -m "message about creating tag"For example, in our myrepos example, we might make some changes and commit and the commit has version number. We could make a v1 tag as follows:
git tag -a v1 c3ac05c -m "Made Version 1"
git fetch --tagsIn our case, we could cd into myrepos2 and then type this line.
cd ../myrepos2 git pull git fetch --tags
git checkout tags/[tag_name]In our example, in myrepos2, we could type:
git checkout tags/v1