许荣@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上操作