上传代码到Git远程仓库(Github)

一 在官网https://github.com/注册一个账号。
二 在网站内创建一个仓库,取名叫code。
三 将本地的文件上传到远程仓库。
[root@localhost ~]# pwd
/root
[root@localhost ~]# echo "# code" >>READE.md
[root@localhost ~]# cat READE.md 
# code
[root@localhost ~]# git init
Initialized empty Git repository in /root/.git/
[root@localhost ~]# git add READE.md
[root@localhost ~]# git commit -m "first commit"
[master (root-commit) 81a76a3] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 READE.md
[root@localhost ~]# git remote add origin https://github.com/cakin24/code.git
[root@localhost ~]# git push -u origin master
Username for 'https://github.com': cakin24
Password for 'https://[email protected]': 
Counting objects: 3, done.
Writing objects: 100% (3/3), 211 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/cakin24/code.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
[root@localhost ~]# vim READE.md 
[root@localhost ~]# git add READE.md
[root@localhost ~]# git commit -m "second commit"
[master f7f5350] second commit
 1 file changed, 1 insertion(+)
[root@localhost ~]# git push -u origin master
Username for 'https://github.com': cakin24
Password for 'https://[email protected]': 
Counting objects: 5, done.
Writing objects: 100% (3/3), 246 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/cakin24/code.git
   81a76a3..f7f5350  master -> master
Branch master set up to track remote branch master from origin.
四 验证是否上传成功

 

 

猜你喜欢

转载自cakin24.iteye.com/blog/2371812