Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. For further details, view the following page at Wikipedia:
Git is installed on all DreamHost servers. As of August 2015, the following version is installed:
[server]$ which git /usr/bin/git [server]$ git --version git version 220.127.116.11
How to set up Git for the first time
When you first set up you Git environment, you'll want to configure a few variables. View the following article for details:
Creating your identity
The following two commands create your username and email address to be used with Git. View the SSH article for details on how to log into your server:
[server]$ git config --global user.name "John Doe" [server]$ git config --global user.email email@example.com
This creates a file named .gitconfig in your user's directory with the following content:
[user] name = John Doe email = firstname.lastname@example.org
Then, check your settings that Git can find by running the following:
[server]$ git config --list user.name=John Doe email@example.com
Setting up the repository and commit
- Navigate to the directory of your application. In the example below, the application is in the directory named /mygitapp.
- Run the following to initialize the new repository:
[server]$ git init Initialized empty Git repository in /home/username/mygitapp/.git/
- This command creates the /.git directory.
- Add all files in your app to the Git repository. The following command shows how to add all files:
[server]$ git add .
- You can also choose specific files if you wish.
- Run the status command to confirm which files are in the staging area:
[server]$ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: file1.txt # new file: file2.txt # new file: file3.txt # new file: subdirectory1/file4.txt #
In this example, you can see the following files are being tracked and ready to be committed:
- file4.txt (Note how this file is in the /subdirectory1 directory)
- If you're sure you're ready to commit these versions of the files, run the following command:
[server]$ git commit -m "first commit" [master (root-commit) 0bd2848] first commit 0 files changed create mode 100644 file1.txt create mode 100644 file2.txt create mode 100644 file3.txt create mode 100644 subdirectory1/file4.txt
- The -m flag allows you to add a message to this commit'.
This creates your first commit which records the snapshot you set up in your staging area. View the following link for further examples and explanations:
Access control with Gitolite
Gitolite allows you to set up fine-grained access controls as other features. Visit the Gitolite GitHub page for further details.