Finding the repository on sourceforge
Getting a copy
Your personal git info
Updating your copy
Committing a change
Reverting local changes
Looking at diffs
Using git on MS Windows
Go to the gretl
project page at
and select the Code item on the taskbar.
Following on from the above: if you are not logged in you will see an instruction by means of which you can grab a read-only copy of the gretl-git sources, namely
git clone git://git.code.sf.net/p/gretl/git gretl-git
If you are logged in under your sourceforge USERNAME, and you have write privileges with CVS, you should see an instruction for getting a read-write copy, on the pattern
git clone ssh://USERNAME@git.code.sf.net/p/gretl/git gretl-git
These are shell commands. Obviously, if you need access to update translations you must use the second command.
Before doing anything substantive with git you should ensure that your basic personal information (name and email address) is known to the program. This can be done via two shell commands on the pattern:
git config --global user.name "Your Name" git config --global user.email "firstname.lastname@example.org"
As you might guess, the above commands will set username and email for any and all git repositories on your local machine, If you wish to set specific data for gretl commits, then change directory to your copy of the gretl-git repository and issue commands on the pattern above but omitting the --global option.
Using CVS, you would update your sources with the command
The equivalent git command is
So, very straightforward.
Using CVS, you would commit a change with the command
(possibly followed by the name of a file, but cvs will
commit any files in the current directory that are
under version control and have been modified by you).
The git equivalent is a sequence of two commands:
git commit <filenames> git push
Note that with git commit you must supply a filename, or a list of
filenames, or use the -a flag to commit all modified files.
Otherwise git will not actually
do anything, but just show you the list
of modified files (which of course can be useful in itself).
Also note that a
commit just registers your changes with your
local git repository. The git push command must
be executed to send your changes to sourceforge.
This information is relevant only for gretl developers, who are in the business of making changes in the gretl code-base. It may happen from time to time (I speak from experience!) that you make some changes in your local copy of the gretl git sources and then decide (before committing) that some of these changes are ill advised, and you want to roll them back.
In the old days of CVS you could simply delete a local file, then do a cvs update to restore the previous version from the repository. But -- watch out! -- git assumes that if you delete a file locally you mean to delete it from version control altogether. So you DO NOT want to do that. The (not very intuitive) git equivalent is
git checkout .
This will revert changes to files that are already
tracked by git
(known to be part of the code base) but not already
staged (set up
for a push via the git commit command).
To revert local changes that you have already committed/staged but not yet pushed, there are two variants:
git reset --soft HEAD~ git reset --hard HEAD~
The first of these just
uncommits the change, but does not revert the
state of your local files to HEAD. The second both uncommits the changes and
reverts your local files (or in other words,
nukes your changes altogether).
For a lot more on reverting changes, see this GitHub blog entry.
To see any updates in your working copy relative to the sourceforge repository, it's simple:
To inspect differences for a specific file, append the name of the file to this command.
To see any updates made in the sourceforge repository relative to your working copy:
git fetch origin git diff HEAD origin/master
Note that unlike pull, a fetch doesn't actually modify the files in your working copy, it just grabs information about what has changed in the repo.
To create a new branch, and then switch onto it:
git branch newbranch git checkout newbranch
or use a shortcut: git checkout -b newbranch.
To switch back to master:
git checkout master
To merge newbranch into master:
git checkout master git merge newbranch
To delete newbranch:
git branch -d newbranch
The following from beanstalk looks like a good guide: Working with Git on Windows.
Allin Cottrell, last revised 2017-01-16