1. Requirements and Environment
Hardware: a pc or virtual machine with an Ubuntu System (tested as Ubuntu11.10)
Software: openssh-server, openssh-client, git-core
2. install and configure the git Server
A. Install ssh. Because git is based on the ssh protocol, you must first install ssh:
- Sudo apt-get install openssh-server openssh-client
After installing ssh, start the ssh service:
- Sudo/etc/init. d/ssh restart
B. Install the git Server:
- Sudo apt-get install git-core
3. Apply for a github account
If you just want to copy the code you are interested in on github to your local computer, or use the git tool to manage the local code, you have completed the configuration of git in ubuntu by executing step 2, you can use git to manage code.
However, if you want to submit the code to github for management, You need to register a new account on github. The specific registration steps are omitted.
4. Configure the ssh Public Key
A. First, generate an ssh Public Key locally.
- Ssh-keygen-C 'your emaildress '-t rsa
For example, ssh-keygen-C 'dongyuchi @ gmail.com '-t rsa
Will be in the user directory ~ /. Ssh/
You can use the ssh-v git@github.com command to test whether the link is unblocked
- Ssh-v git@github.com
B. Upload the public key to github.
In the account profile, select the ssh keys option and Add the SSH Key ~ The content in/. ssh/id_rsa.pub is copied and uploaded.
After the upload is successful, you will receive a confirmation email. You can use the ssh-v git@github.com command to test whether the link is unblocked.
5. manage projects
A. Create a warehouse
Create a new directory as the repository directory. Go to the directory and run the git init command to initialize the repository. After the initialization is complete, A. git hidden file is added to the directory.
- Git init
B. git Configuration
- Git config -- global user. name "Your Real Name"
- Git config -- global user. email you@email.address
C. Add a file
- Git add ./
This is to add all files under the directory. If you only add a file, the file name will be listed. if you add a directory, you can use * instead.
D. commit Project
- Git commit-m' my first version
-M is followed by a description of the project.
E. Upload a project
- Git remote add origin git@github.com: Your github user name/Your github project name. git
- Git push origin master
When executing push in this step, the system may require you to pull first, then pull first, and then push again.