This article is an introduction to using the Git version control system on MucaHost Hosting servers.
The popular Git version control system is installed on all MucaHost Hosting servers. The following sections are a brief introduction to Git's basic features.
Creating a repository
To create a Git repository, all you have to do is log in to your MucaHost account using SSH, and then type the following command:
git init REPOSITORY
Replace REPOSITORY with the name of the directory where you want to create the repository (if the directory does not already exist, the git init command creates it).
To take a snapshot of all of the files currently in the directory, type the following command:
git add .
The git add command puts the files in a temporary staging area that Git calls the “index”. To commit the files to the repository permanently, type the following command:
A text editor opens, and you can type a commit message that describes the changes. Save the message, and then Git adds the changes to the repository.
You may receive the following message when you try to commit changes:
Please tell me who you are.
If you receive this message, type the following commands, using your own e-mail address and name:
git config --global user.email "email@example.com" git config --global user.name "Your Name"
Making changes to a repository
Git makes it easy to update a repository. After you edit a file or files, you update Git's file “snapshot” by using the git add command. To make the changes to the repository permanent, use the git commit command.
You can combine the git add and git commit commands by typing the following command instead:
git commit -a
You can even include the commit message on the command line by using the -m option. Replace message with your commit message:
git commit -a -m "message"
To view changes you have made to files in the repository since the last commit, type the following command:
Similarly, to view a list of changes that have already been committed to the repository, type the following command:
Working with branches
A single Git repository can maintain multiple development branches. For example, you could create a “testing” branch and a “production” branch to track changes for different versions.
To create a new branch, type the following command, replacing NAME with the name of the new branch:
git branch NAME
To see a list of all branches in a repository, type the following command:
The asterisk (*) next to a branch name indicates the current working branch. If you want to work on another branch, type the following command, replacing NAME with the name of the branch:
git checkout NAME
You can then make changes in the branch and commit them with the git commit command. If you switch to another branch, you will not see those changes in the branch.
Merging changes from another branch
To merge changes from one branch into another branch, type the following command. Replace NAME with the name of branch that has the changes you want to merge:
git merge NAME
The changes in source branch NAME are then merged into the destination branch (the current working directory).
Cloning a repository
You can “clone” repositories. When you clone a repository, git makes an exact copy of an existing repository. For example, say you have a repository named project. To clone the repository into a directory named projectclone, you would type the following command, replacing username with your own account username:
git clone /home/username/project /home/username/projectclone
Now there is an exact copy of the project repository in the projectclone directory.
Suppose you (or another developer) make changes in the projectclone directory that you want to pull back into the original project directory. To do this, you would type the following commands, replacing username with your own account username:
cd /home/username/project git pull /home/username/projectclone master
The git pull command fulfills two functions. First, it fetches changes from a remote repository (in this case, the projectclone repository). Second, it merges those changes into the current working repository (in this case, the project repository).
If you try to clone a Git repository stored on a remote server (such as GitHub) by using HTTPS, you may receive the following error message:
error: error setting certificate verify locations: CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none while accessing https://example.com/repository/ fatal: HTTP request failed
This error occurs when your account has the jailshell enabled. Please open a ticket on the Customer Portal at our client area https://mucahost.com and request normal shell access for your account.
To view the official Git documentation, including references guides, tutorials, cheat sheets, and more, please visit http://git-scm.com/documentation.
- using git, git tutorial, use git on web server, using git on shared hosting
- 0 Users Found This Useful
Powered by WHMCompleteSolution