This page is intended to address the typical git commands that someone working on Dynare will use in an average day of work. A useful web page where you can find more information about the most commonly used git commands can be found on the Everyday GIT page.

Daily Use

Before you start working

Every day, before you begin working (and as commits are pushed to the central git repository), you should bring your local git repository into line with the central repository. Following this procedure regularly will make dealing with conflicts more manageable as you will deal with them as they arise as opposed to later on when you are ready to submit your local commits to the local repository.

In order to do this, you should issue the following commands.

$ git stash
$ git fetch
$ git rebase origin/master
$ git stash pop

git stash is intended to put the git-tracked files (i.e., those that already exist in the central repository) that you have modified locally onto a temporary Work-In-Progress stack. The intention of this command is to clean your workspace and prepare it for rebasing.

git fetch will download the changes between your local repository and the central repository.

git rebase origin/master will realign your local repository with the central repository, placing any local commits that you may have on top of the latest commit in the central repository.

git stash pop will pop your previously stashed work off of the Work-In-Progress stack onto your now-updated local git repository.

As you work

As you proceed in your project, you should commit your completed work to your local repository. A commit represents a logically-sized portion of your changes. The number of files in a commit can vary from one line in one file (typically for a bug fix) to thousands of lines in hundreds of files. However, the logic underpinning each commit is the same: the changes within the commit make sense when grouped together.

To commit your work locally, you should do the following:

$ git add <<filename>>
$ git commit -m "<<commit message>>"

git add <<filename>> adds a snapshot of a file in its currently modified state to the list of files to be included in the next commit. If you make any changes to the file after having executed a git add command, you will have to execute the command again to include these changes in the commit. Needless to say, this command will be executed at least once for every file you want to include in your commit. NB: Do not add binary files to your commit as git cannot keep track of binary changes and hence their inclusion in the repo will cause it to become bloated.

git commit -m <<commit message>> will create a local commit with the associated message. This is only a local change.

When the project is finished

When you have finished the entire project, you must submit your work to your personal space on github so either St├ęphane or Michel can OK it and push it into the central repository. Before you do this, make sure to update your personal repository and rebase it via the git fetch and git rebase origin/master commands described above. This will ensure that there are no merge conflicts and also help maintain a logically consistent central repository (i.e., all files of an associated project will be entered together in the repository).

Once you have brought your local repository up to date and dealt with any conflicts, you will issue the following command to send the commits to your personal directory on Kirikou:

$ git push personal

If you have changes in your personal directory that have not been incorporated into the central repository, you will need to either wait until those commits are included in the central repository or issue this command with the -f option, which will overwrite the contents in your personal space.

DynareWiki: GitDailyWorkFlow (last edited 2014-10-14 12:18:26 by HoutanBastani)