git status查看文件的状态
提要
通過git status查看文件的狀態時,出現了一些如下的提示:
jidfj@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git status On branch master Your branch is behind 'origin/master' by 8 commits, and can be fast-forwarded.(use "git pull" to update your local branch)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: SceneModule/SceneComponent/layoutListwidget.cppmodified: ZhuShouMainFrame.pro.userUntracked files:(use "git add <file>..." to include in what will be committed)ZhuShouMainFrame.pro.user.546ac14no changes added to commit (use "git add" and/or "git commit -a")這時對于新手就不知該如何操作,其實只需根據提示,結合自己的需求,輸入指令。
實現
像上面出現的情況,我是在更新了項目之后出現了這樣的問題,于是金國一系列的查找終于了解了一些。
支隊上面的提示,我想著添加修改到gitlab上,于是我輸入了指令:git add 。如下面所示:
這時并沒有提交更改到暫存區,也就是提交沒有結束,若想將修改提交到gitlab上,需要繼續輸入指令:git commit -a -m “描述”。然后緊接著輸入git push指令。才能將修改提交上去。
但是我并不想提交這次修改,所以可以采用下面的指令:
git restore
將在工作區但不在暫存區的文件撤銷修改,文件的內容恢復到沒有修改之前。就是將本地這一次不應該上傳已經的文件撤銷,但是可以看到還是有一些文件的狀態還是不怎么正常。
緊接著執行指令:
先將文件ZhuShouMainFrame.pro.user.546ac14合并,之后更新了代碼,然后又查看了文件的狀態,可以看到還是有文件狀態不怎么看著舒服,接著輸入下面的指令。
sddi@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git restore --staged SceneModule/SceneComponent/layoutListwidget.cppsddi@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git status On branch master Your branch is behind 'origin/master' by 8 commits, and can be fast-forwarded.(use "git pull" to update your local branch)Changes to be committed:(use "git restore --staged <file>..." to unstage)new file: ZhuShouMainFrame.pro.user.546ac14Changes 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: SceneModule/SceneComponent/layoutListwidget.cpp上面的提示指出可以通過忽略本次文件在工作區的更改,于是我就忽略了。輸入指令:
sdss@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git restore SceneModule/SceneComponent/layoutListwidget.cppsada@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git status On branch master Your branch is behind 'origin/master' by 8 commits, and can be fast-forwarded.(use "git pull" to update your local branch)Changes to be committed:(use "git restore --staged <file>..." to unstage)new file: ZhuShouMainFrame.pro.user.546ac14sada@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git pull Updating 77e467a..e1727c0 Fast-forwardDecoderPainter/playwidget.cpp | 4 +-LoginManager/LoginManager.cpp | 14 +-LoginManager/LoginManager.h | 1 +MessageCenter/messagecenter.cpp | 12 +-MessageCenter/messagecenter.h | 4 +-NetWork/networkclienthttp.cpp | 7 +NetWork/networkclienthttp.h | 2 +-SIgnalList/listwindows.cpp | 4 +-.../qss/psblack/SignalList.css | 0SIgnalList/qssFile.qrc | 1 +SceneModule/SceneComponent/layoutListwidget.cpp | 6 +-ScreenPreview/priviewnavigator.cpp | 52 ++--ScreenPreview/signalwin.cpp | 28 +-SourceControl/controlevent.cpp | 1 -TimeLine/mainframe.h | 7 +-ZhuShouMainFrame.pro.user | 18 +-ZhuShouMainFrame.pro.user.546ac14 | 337 +++++++++++++++++++++ZhuShouMainFrame.ui | 10 +-18 files changed, 430 insertions(+), 78 deletions(-)rename "\351\234\200\350\246\201\346\267\273\345\212\240\345\210\260\350\277\220\350\241\214\347\233\256\345\275\225\347\232\204\346\226\207\344\273\266/SignalList.css" => SIgnalList/qss/psblack/SignalList.css (100%)create mode 100644 ZhuShouMainFrame.pro.user.546ac14sada@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git status On branch master Your branch is up to date with 'origin/master'.nothing to commit, working tree cleansada@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git pull Already up to date.經過一頓亂操作,可以看到現在查看代碼的狀態的時候是正常的狀態,看著順眼了。
作者也是第一次使用gitlab很多不懂,還望指教。
總結
1.git restore
撤銷本次在工作區但是沒有在暫存區的文件內容的更改。
2.git restore --staged
將暫存區的文件從暫存區撤出,不改變文件的內容。
總結
以上是生活随笔為你收集整理的git status查看文件的状态的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gbase迁移mysql_基于datax
- 下一篇: bootstrap table移动端_b