git-添加远程库

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop
$ cd learngit

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$ git remote add origin https://github.com/xurong/learngit.git

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$ git push -u origin master



许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$ git remote add origin https://github.com/learngit.git
error: remote origin already exists.

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$ echo "# learngit" >> README.md

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$ git init
Reinitialized existing Git repository in C:/Users/许荣/Desktop/learngit/.git/

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$ git add README.md
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$ git commit -m "first commit"
[master 1b7f4b2] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (master)
$ git branch -M main

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git remote add origin https://github.com/xurong/learngit.git
error: remote origin already exists.

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git push -u origin main
Enumerating objects: 32, done.
Counting objects: 100% (32/32), done.
Delta compression using up to 8 threads
Compressing objects: 100% (28/28), done.
Writing objects: 100% (32/32), 2.70 KiB | 921.00 KiB/s, done.
Total 32 (delta 12), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (12/12), done.
To https://github.com/xurong/learngit.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git remote -v
origin  https://github.com/xurong/learngit.git (fetch)
origin  https://github.com/xurong/learngit.git (push)

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git remote rm origin

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ echo "# learngit" >> README.md

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git init
Reinitialized existing Git repository in C:/Users/许荣/Desktop/learngit/.git/

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git remote add origin https://github.com/xurong/learngit.git

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git push -u origin main
Everything up-to-date
Branch 'main' set up to track remote branch 'main' from 'origin'.

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git remote -v
origin  https://github.com/xurong/learngit.git (fetch)
origin  https://github.com/xurong/learngit.git (push)

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git remote rm origin

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
$ git status
On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   README.md

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

许荣@DESKTOP-A30VNHE MINGW64 ~/Desktop/learngit (main)
命令说明:
1.
$ echo "# learngit" >> README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git branch -M main
$ git remote add origin https://github.com/xurong/learngit.git
$ git push -u origin main
解释:以上为GitHub提示将.git版本库远程复制到自己的GitHub,并命名为origin,创建远程库。
2.
$ git remote -v
解释:查看远程信息
3.
$ git remote rm origin
断开本地库与远程库练习,而非删除,彻底删除需要在GitHub上操作
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值