Github 使用

2018-04-18  本文已影响19人  捞小虾

Github 使用

On Ubuntu
root@server_1:/var# cd /etc/ssh
root@server_1:/etc/ssh# ssh-keygen -t git -C "YourEmailAddress"

# git & git.pub 秘钥对
root@server_1:/etc/ssh# ls
git 
git.pub
# ssh_config 文件
Host *
Hostname github.com
PubKeyAuthentication yes
IdentityFile /etc/ssh/git
root@server_1:/var/HttpTestProject# ls -a
.
..
.git               
.gitignore
HttpTest 
README.md
# 初始化代码库
root@server_1:/var/HttpTestProject# git init
Reinitialized existing Git repository in /var/HttpTestProject/.git/

# 添加文件到版本库
git add '文件或者文件夹'

# 提交,产生版本记录,注意代码依然在本地
git commit -m "comment"

# 将本地代码上传到 github
git remote add origin 'URL of your codes on github'
# 如果出现 fatal: remote origin already exists. 提示
# 执行 git remote rm origin 后重新执行 git remote add origin 命令
git push --set-upstream origin master

root@server_1:/var/HttpTestProject# git push --set-upstream origin master
Counting objects: 23, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (23/23), 5.55 KiB | 0 bytes/s, done.
Total 23 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
To URL of your codes on github
   2cbc8c1..12b7df5  master -> master
Branch master set up to track remote branch master from origin.
git add <file>
git commit -m "comment"
git push origin master
On Win10
上一篇下一篇

猜你喜欢

热点阅读