Add User Information
The first is to configure your personal user name and e-mail address. These two configuration is very important, will quote two pieces of information each time you submit Git, indicating who submitted the update, it will be permanently included with the update history together:
|
|
SSH key generated and added to github
Check whether they have been ssh keys: cd ~/.ssh
. If no key not have this folder, delete the backup there.
ssh-keygen -t rsa -C “你的注册邮箱”
Press 3 Enter the password is blank. Finally we got the two files: id_rsa and id_rsa.pub, to add id_rsa.pub all of SSH Keys in github.
New working directory, and initialize a new local warehouse
|
|
Adding a remote repository and push data to a remote warehouse
- To add a new remote repository, you can specify a simple name, for future reference, run
git remote add [shortname] [url]
Here's what the name is origin added warehouse, this is usually the default.
|
|
- Local data warehouse pushed to the remote repository. Order to achieve this task is simple:
git push [remote-name] [branch-name]
.
If the master branch should be pushed to the origin server (Again, the clone operation will automatically default master name and origin), run the following command:
After the above-described operation is repeated (excluding the operation of the init and romote)
Other commonly used commands
- Update Project (added a new file):
|
|
|
|
- 更新项目(没新加文件,只有删除或者修改文件):
|
|
- 忽略一些文件,比如*.o等:
|
|
- clone代码到本地:
|
|
- 撤销
git reset
- 删除
git rm *
// 不是用rm
常见错误
1.$ git remote add origin [email protected]:zhongyouhuiwu/ceshi.git
错误提示:fatal: remote origin already exists.
解决办法:$ git remote rm origin
然后在执行:$ git remote add origin
[email protected]:zhongyouhuiwu/ceshi.git
就不会报错误了
$ git push origin master
错误提示:error:failed to push som refs to
解决办法:$ git pull origin master
//先把远程服务器github上面的文件拉先来,再push 上去。