Git

1. 首先在github上创建repository 我的仓库名叫 shellscript

2. 在Centos6.5上创建目录,加入README.md 简介,并git初始化

[root@nagios-client02 wzz]# cd wzz_git/

[root@nagios-client02 wzz_git]# ll
total 12
-rw-r--r--. 1 root root 15 Jan 28 20:41 1.txt
-rw-r--r--. 1 root root 10 Jan 28 21:04 2.txt
-rw-r--r--. 1 root root  7 Jan 28 21:04 README.md


[root@nagios-client02 wzz_git]# echo "# shellscript" > README.md

[root@nagios-client02 wzz_git]# cat README.md

# shellscript


[root@nagios-client02 wzz_git]# git init

Reinitialized existing Git repository in /home/wzz/wzz_git/.git/

3. commit提交、把暂存区的所有内容提交到当前分支master

[root@nagios-client02 wzz_git]# git commit -m "first commit"
# On branch master
# Your branch is ahead of 'learngit/master' by 1 commit.
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#    modified:   README.md
#

no changes added to commit (use "git add" and/or "git commit -a")


4. 添加远程库:git remote add origin git@github.com:supermenxxx/shellscript.git

出现的问题(1)

[root@nagios-client02 wzz_git]# git remote add origin https://github.com/supermenxxx/shellscript.git

fatal: remote origin already exists.

解决方法:

[root@nagios-client02 wzz_git]# git remote rm origin


5. 把本地库的内容推送到远程

[root@nagios-client02 wzz_git]# git push -u origin master

Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。

推送成功后,可以立刻在GitHub页面中看到远程库的内容已经和本地一模一样:


出现的问题(2)


error: The requested URL returned error: 403 Forbidden while accessing https://github.com/supermenxxx/shellscript.git/info/refs

fatal: HTTP request failed

解决方法(2)

[root@nagios-client02 wzz_git]# git remote set-url origin ssh://git@github.com/supermenxxx/shellscript.git
[root@nagios-client02 wzz_git]# git push -u origin master
Counting objects: 7, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (7/7), 504 bytes, done.
Total 7 (delta 0), reused 0 (delta 0)
To ssh://git@github.com/supermenxxx/shellscript.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值