Committing

From Geos-chem
Revision as of 15:46, 20 June 2019 by Bmy (Talk | contribs) (Created page with " == Overview == == Creating a commit with Git GUI == With Git, you should commit frequently, such as when you have completed making revisions to a file or group of files. C...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

Creating a commit with Git GUI

With Git, you should commit frequently, such as when you have completed making revisions to a file or group of files. Commits that are made on one branch will not affect the other branches.

Committing is best done with the Git GUI. Follow these steps:

GitGuiCommitMenu.png

  1. Pick Commit/Rescan from the menu (or type the F5 key) to force the git gui to show the latest changes.
  2. You should get a list of files in the Unstaged Changes window. Clicking on the icons on the left of the file names will send them to the Staged Changes window. Git will add all of the files in Staged Changes to the repository on the next time you commit. Note: Clicking on the icon of the files in the Staged Changes moves back the file to the Unstaged Changes window.
  3. Type a Commit message in the bottom right window. See this example of a good commit message. Some pointers are:
    1. The first line should only be 50 characters or less and succinctly describe the commit
    2. Then leave a blank line
    3. Then add more in-depth text that describes the commit
    4. Then click on the Signed-off by button. This will add your name, email address, and a timestamp. Note: To modify your name and email address, edit the .gitconfig file in your home directory.
  4. There are two radio buttons above the Commit message window.
    1. New commit: This is the default. Assumes we are making a totally new commit.
    2. Amend last commit: If for whatever reason we need to update the last commit message, pick this button.
  5. Click on the Commit button.

If you then gitk viewer, your new commit should be visible.

Renaming or moving files

In some instances you may find it necessary to rename files. For example, in GEOS-Chem v9-01-02, we have had to rename file ending in .f to .F and .f90 to .F90. If only the name of the file changes, then Git will recognize it as a renamed file in the repository. To rename a file, follow these steps:

  1. Change the name of the file with the Unix mv command. For example: mv myfile.f myfile.F
  2. Open the git gui. You will see the two files myfile.f and myfile.F listed in the Unstaged Changes window.
  3. Click on myfile.f and myfile.F; this will move them to the Staged Changes window.
  4. In Staged Changes you will see:
    1. File myfile.f is slated to be removed (i.e. a red "X" is listed next to the file name).
    2. File myfile.F is slated to be added (i.e. a green checkmark is listed next to the file name).
  5. Add a commit message, sign off, and click Commit as described above.
  6. Start the gitk browser. In the lower left window, you should see text such as:
  ---------------- GeosCore/myfile.F --------------------------
  similarity index 100%
  rename from GeosCore/myfile.f
  rename to GeosCore/myfile.F

From this point forward, file myfile.F will use the *.F file extension. However, it will still possess the total revision history from when the file was still named myfile.f. If you merge changes from another repository that still has myfile.f, then these changes will be seamlessly integrated into myfile.F.