Difference between revisions of "Viewing the revision history"

From Geos-chem
Jump to: navigation, search
(Using Gitk to examine the version history)
(Using the Git GUI browser for source code management)
Line 32: Line 32:
  
 
       git gui &
 
       git gui &
 +
 +
which will bring up this window:
 +
 +
[[Image:GitGui.png]]
  
 
On the left there are 2 windows:
 
On the left there are 2 windows:

Revision as of 15:54, 19 June 2019

Previous | Next | Guide to using Git with GEOS-Chem | Getting Started with GEOS-Chem | GEOS-Chem Main Page

Using Gitk to examine the version history

The best way to examine the contents of your Git-backed GEOS-Chem source code is to use the gitk viewer. There are two ways to do this:

(1) Change into your code directory and start gitk as follows:
       gitk --all &       # This will show ALL open branches
(2) Or if you are using the git gui GUI browser (more on that below), you can invoke gitk from the Repository/Visualize master's History menu item.

At the top left of the gitk screen, you will see the graph of revisions.

Gitk.png

Each dot represents a commit, along with the log message that accompanied each commit.

Note that at the most recent commit (i.e. the line at the very top) there are 2 green boxes, one labeled master and one labeled remotes/origin/master:

  1. remotes/origin/master: This was the state of the repository on the remote server when you checked it out for the first time. Therefore, this is the "pristine", unchanged code that you got from the download.
  2. master: This is the current state of the local repository now. Since we haven't done anything to the code yet, master and remotes/origin/master point to the same commit.

If you click on any of the commits in the top left window, in the window below, you will see the log message and a list of changes to the source code. The old code is marked in RED and the new code is marked in GREEN. At right you will also see a list of files that were changed during the commit.

With gitk, it's really easy to see how the code has evolved over time.

Using the Git GUI browser for source code management

We recommend using the git gui for source code management. Start this in your code directory:

     git gui &

which will bring up this window:

GitGui.png

On the left there are 2 windows:

  1. Unstaged Changes: An unstaged change is a modification that Git does not know about yet. If you modified any files since the last commit, then they should be displayed in this window. Also, right above this window you will find the name of the current checked-out branch.
  2. Staged Changes: These are changes that Git will add to the repository the very next time you make a commit.

In general, anytime you need to modify the source code, you should NOT do it on the master branch. You should create a new branch for your modifications. Then you can test your modifications ad nauseum until you are sure that everything is functioning as it should. When your modifications are complete, you can merge your branch into the master branch. You can then delete the branch you created.

The advantage of this approach is that if you ever need to start over from scratch, you can just go back to the master branch and you will get back the state of the code before your modifications were added.

Further reading

--Bob Yantosca (talk) 15:40, 19 June 2019 (UTC)


Previous | Next | Guide to using Git with GEOS-Chem | Getting Started with GEOS-Chem | GEOS-Chem Main Page