Using Git to track module development#why would you want to use git? because...
mainly because checking out the modules project won't allow you to track your own changes unless you have write access to svn (develop on this idea).
Work in progress, please feel free to add/amend.
Git installation#The following sections will help you with the installation of git in your own system.
Linux#Git can be installed from most package managers. Follow this guide if you use Ubuntu.
Mac#Can be installed from a dmg file and mac ports. (develop)
Windows#Can be used through Cygwin.
Git initial config#Git uses your user name and email address to track changes to the different repos. A general configuration (that can be override per repo) can be set with the following commands:
> git config --global user.name "my_user_name" > git config --global user.email "my_email_address_AT_mail_provider.com"
To check your current values you can use:
> git config --global --listGit is very configurable, you can see more options here
Most used commands#
|init||Initialise your repo|
|clone||clone someone else's repo - (equivalent to checkout in svn)|
|status||lists of the different tracked and untracked files in your local repository|
|add||add files to be tracked by git|
|commit||commit files to your local repo|
|push||push files against the remote server (equivalent to commit in svn)|
|pull||pull changes from the remote repo (equivalent to update in svn)|
|branch||the concept of branch might be the same as in a centralised system, but it is used in a completely different way (develop).|
|checkout||change between local branches|
Note: pull = fetch + merge
- --dry-run - runs the command without making any changes, and reports on results.
Tips and tricks
- a file called .gitignore can contain the files/regular expressions of files you don't want to track
- git does not track empty directories. There are different tricks to deal with this.
GUIs#gitk: it comes with the default install of git and can be used by invoking on the command line
jos$ gitk --all
Command line examples#Local Repository: Creating a project from scratch at git_repo_example in our local machine.
jos@ceres:/tmp$ mkdir git_repo_example jos@ceres:/tmp$ cd git_repo_example/ jos@ceres:/tmp/git_repo_example$ git init Initialized empty Git repository in /tmp/git_repo_example/.git/ jos@ceres:/tmp/git_repo_example$ nano README <--- nano is a text editor. edit/create the file with whichever editor you fancy! ---> jos@ceres:/tmp/git_repo_example$ git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track) jos@ceres:/tmp/git_repo_example$ git add README jos@ceres:/tmp/git_repo_example$ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: README # jos@ceres:/tmp/git_repo_example$ git commit -m "Commiting README to the local repo" [master (root-commit) 484f9a2] Commiting README to the local repo 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 README jos@ceres:/tmp/git_repo_example$ git status # On branch master nothing to commit (working directory clean) jos@ceres:/tmp/git_repo_example$ git log commit 484f9a21afec51da09ebe0599ee581e64935b843 Author: Jose Dominguez <jos@xxxx> Date: Thu Oct 7 15:02:52 2010 +0100 Commiting README to the local repo
Remote Repository: Cloning in read-only mode.
jos$ git clone git://github.com/josmas/git_repo_example.git Initialized empty Git repository in /private/tmp/git_repo_example/.git/ remote: Counting objects: 6, done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 1), reused 0 (delta 0) Receiving objects: 100% (6/6), done. Resolving deltas: 100% (1/1), done. jos$ cd git_repo_example/ jos$ git status # On branch master nothing to commit (working directory clean) jos$ nano README <--- nano is a text editor. edit/create the file with whichever editor you fancy! ---> jos$ git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: README # no changes added to commit (use "git add" and/or "git commit -a") jos$ git add README jos$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: README # jos$ git commit -m "Adding more changes to README" [master 17f3918] Adding more changes to README 1 files changed, 2 insertions(+), 0 deletions(-) jos$ git push <--- you can only 'push' if you have permissions to do so. it would not work in this case (read-only). --->
Centralised vs. Distributed version control#(try to keep it simple!)
After installing and configuring git, you will have to generate ssh keys and config your github token if you want to interact with github. In this guide we are only concerned about free git accounts. If you have a paid account, or more than one account, the process might be slightly different.
Forking the subsnapshots project for collaboration#
- Log in to your github account and navigate to the main source of this module at subsnapshots source.
- Click on the 'Fork' button to generate your own copy of the project. More info.
- Once forked, the project will appear in your dashboard, and you will be able to clone it with write permissions.
- When you have made changes, committed locally and pushed them to github again (your fork of the project), you can fill in a pull request to the original developer. Detailed instructions