1. Install git
Open the terminal, enter the command sudo apt-get install git
to install
sudo apt-get install git
Enter git
check whether the installation was successful
2. Configure a public key
Git configuration after installation for
sequentially input instruction
git config --global user.name "你的名字"
git config --global user.email "你的邮箱地址"
After configuration, you need to create a public key used to verify, because the git repository is accessed by way of ssh, we need to create a file verification locally. Use the command ssh-keygen -C 'you email [email protected]' -t rsa
(no space between ssh and -keygen), will be in the user directory ~/.ssh/
to establish the appropriate key file.
ssh-keygen -C '你的邮箱地址' -t rsa
Process needs to press the Enter key three times
3. Create a public viewing
cd ~/.ssh
gedit id_rsa.pub
4. git repository submit
git init #初始化一个git仓库
git add <file> #添加文件
git commit -m <message> #提交至仓库。
git remote add origin https://git.oschina.net/你的用户名/项目名.git
git push origin master
git commit
Command, -m
entered followed by explanation of this submission, you can enter any of the content, of course, the best is meaningful, so you can from the history list easy to find change records.
Why add files Git needs add
, commit
a total of two steps it? Because commit
it can submit many files at once, so you can multiple add
different files, such as:
git add file1.txt
git add file2.txt file3.txt
git commit -m "add 3 files."