CS175
Chris Pollett
Sep 17, 2014
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"