Using minimial git over Dropbox

When writing collaboratively, there is often a need to make changes and diplay the changes to others over the web. Git provides a way of making changes to text in such a way that no previous changes will be completely deleted, while still presenting a finished product at all times.

In order to simplify the process, Dropbox will be used in place of the regular git push/pull mechanisms. This means all users will be editing the same repo, which makes the whole git process very simple.

In this overview, I will try to give only the minimal set of commands most useful for editing text documents.

Setting up the software

name = Patrick Malsom
email =
pager = less -+S

clog = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
cdiff = diff --color --color-words

Overview of base commands

Status of the repository

git status

This will show the status of the git repo (ie: if any files need to be committed/added)

Adding a new file to the repository

Any new files that you wish to include in the repository must be added explicitly when they are created. This following will add file.txt to the repo

git add file.txt

Saving changes to the repository

Simply edit the file as you normally would. There is no need to keep any of the old text in the document, simply delete it and put the corrected text in. The changes to the old text can can be viewed using git functionality (explained later)

git commit -a -m "commit message"

The above command will save your changes to the git repository. Note that you should add your own message in the string at the end, that describes your change (optional).

Viewing the git log

There is a log of every committed (saved) change that can be easily viewed. One of the aliases defined above is clog (color log). Try using this command now

git clog

This command will show previous commits, similar to the following

* 04fac32 - (HEAD, master) Another commit (1 hour ago) <Patrick Malsom>
* 7882e22 - Some changes (2 hours ago) <Patrick Malsom>

There are a couple things to pay attention to here. The commit message that was used for the commit is shown, along with the date and the author. There is also a number at the front of each log entry (ex:04fac32). This is the hash of the commit and is used to refer to each commit in other commands.

Viewing changes between two commits

Another alias defined above is cdiff (color diff). This command takes a commit hash and returns the differences between the current state and the state at the previous commit.

git cdiff 7882e22

This command will show the changes between commit 04fac32 and 7882e22

Viewing the file from some previous state

It could be useful to see the file as it was at some previous commit. This is achieved with the show command. Assume for this example that there is a file named file.txt in the repo.

git show 7882e22:file.txt

This will simply print out file.txt to the terminal.