Git on cs

Some quick commands for setting up a clone of the git system on cs.

Use the following commands to clone the repository in your local  machine or your cs1 directory.
# clone the repo from server
$ git clone ssh://

where username is your cs login. This is a one time command.

# cd to pums

# get the latest version
$ git pull

# See the changes so far
$ git log

#  edit your files

# See the changes you made
$ git status

$ git diff

# add updates and commit locally
# add any new files
$ git add  <file(s)> 

# add and commit
$ git commit -a -m 'comment updated your changes'

It will be always useful to add *detailed* comments about your changes.
I recommend you *not* to give an inline comment (as shown above). Instead,
if you type:
$ git commit -a
and press ENTER, git opens your default editor, with more detailed information
on the updated files. Remove the '#' and give proper commit messages. Git commits when you
save the message file. This is a local commit. See
$ git log
to see some of the commit messages I have given so far.

More commands:
# Revert back to last commited version. Replace HEAD with any version name.
$ git checkout HEAD -- filename

# push changes to server
$ git push
# Make sure your commits dont break the system before pushing to the server.

# Conflict merging
# This has to be done when the same file is updated by two people and both try to push changes
# to the server.
# git tries to automatically merge as much as possible, but the final merging must
# be done or confirmed manually.

$ git mergetool

Conflicts are marked in a file with clear line breaks:

 <<<<<<< HEAD:mergetest
 This is my third line
 This is a fourth line I am adding
 >>>>>>> 4e2b407f501b68f8588aa645acafffa0224b9b78:mergetest

<<<<<<<: Indicates the start of the lines that had a merge conflict. The first set of lines are the lines from the file that you were trying to merge the changes into.

=======: Indicates the break point used for comparison. Breaks up changes that user has committed (above) to changes coming from merge (below) to visually see the differences.

>>>>>>>: Indicates the end of the lines that had a merge conflict.

How do I resolve a merge conflict in a file?

You resolve a conflict by editing the file to manually merge the parts of the file that git had trouble merging. This may mean discarding either your changes or someone else's or doing a mix of the two. You will also need to delete the '<<<<<<<', '=======', and '>>>>>>>' in the file.

More links: