Git各区的添加与撤销[实际操作验证]
生活随笔
收集整理的這篇文章主要介紹了
Git各区的添加与撤销[实际操作验证]
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
語法
Git分三個區
? ? ? ? ? ? ? ? ? ? 工作區----(add)--->暫存區----(commit)--->本地版本庫----(push)---->遠程版本庫
工作區的取消
git restore 文件名字暫存區git add .? 后的取消??
git restore --staged ?PHPInterview/2.strpos.php本地版本庫git commit? 后的取消??
$ git log -2 選擇倒數第二個 $ git reset --soft ec9bf0be9942e9f17e0431bd88c2737622353154遠程版本庫git push后的? ?
$ git log -2 選擇倒數第二個 $ git reset --hard ec9bf0be9942e9f17e0431bd88c2737622353154 此處不可git pull $ git push --force工作區例子
Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git status On branch master Your branch is up to date with 'origin/master'.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: PHPInterview/2.strpos.phpno changes added to commit (use "git add" and/or "git commit -a")Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git restore PHPInterview/2.strpos.phpAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git status On branch master Your branch is up to date with 'origin/master'.nothing to commit, working tree cleanAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)?暫存區例子
Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git status On branch master Your branch is up to date with 'origin/master'.Changes to be committed:(use "git restore --staged <file>..." to unstage)modified: PHPInterview/2.strpos.phpAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git restore --staged PHPInterview/2.strpos.phpAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git status On branch master Your branch is up to date with 'origin/master'.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: PHPInterview/2.strpos.phpno changes added to commit (use "git add" and/or "git commit -a")本地版本庫例子
Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit.(use "git push" to publish your local commits)nothing to commit, working tree cleanAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git log -2 commit 45ce87d9ce1505a11a7f67a61e0c4acfa950a972 (HEAD -> master) Author: 7117 <qinglangsalaheiyou@163.com> Date: Fri Nov 13 11:16:40 2020 +0800echocommit ec9bf0be9942e9f17e0431bd88c2737622353154 (origin/master) Author: 7117 <qinglangsalaheiyou@163.com> Date: Tue Oct 27 13:07:57 2020 +08001Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git reset --soft ec9bf0be9942e9f17e0431bd88c2737622353154Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git status On branch master Your branch is up to date with 'origin/master'.Changes to be committed:(use "git restore --staged <file>..." to unstage)modified: PHPInterview/2.strpos.php遠程版本庫回退例子
$ git log -2 commit 30f126a4a49c6036444e6fee7fdc6d0fe45f58f7 (HEAD -> master, origin/master) Author: 7117 <qinglangsalaheiyou@163.com> Date: Fri Nov 13 11:18:51 2020 +0800echo 2commit ec9bf0be9942e9f17e0431bd88c2737622353154 Author: 7117 <qinglangsalaheiyou@163.com> Date: Tue Oct 27 13:07:57 2020 +08001Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git reset --hard ec9bf0be9942e9f17e0431bd88c2737622353154 HEAD is now at ec9bf0b 1Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git status On branch master Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.(use "git pull" to update your local branch)nothing to commit, working tree cleanAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master) $ git push --force fatal: HttpRequestException encountered.????????????? Total 0 (delta 0), reused 0 (delta 0) remote: This repository moved. Please use the new location: remote: https://github.com/7117/phpCollection.git remote: remote: GitHub found 4 vulnerabilities on 7117/phpCollection's default branch (2 high, 2 low). To find out more, visit: remote: https://github.com/7117/phpCollection/network/alerts remote: To https://github.com/7117/CodePractice+ 30f126a...ec9bf0b master -> master (forced update)?
總結
以上是生活随笔為你收集整理的Git各区的添加与撤销[实际操作验证]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HTML的a标签置灰不可点击
- 下一篇: 白玉菇的家常做法?