git status查看文件的状态
提要
通過git status查看文件的狀態(tài)時(shí),出現(xiàn)了一些如下的提示:
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")這時(shí)對(duì)于新手就不知該如何操作,其實(shí)只需根據(jù)提示,結(jié)合自己的需求,輸入指令。
實(shí)現(xiàn)
像上面出現(xiàn)的情況,我是在更新了項(xiàng)目之后出現(xiàn)了這樣的問題,于是金國(guó)一系列的查找終于了解了一些。
支隊(duì)上面的提示,我想著添加修改到gitlab上,于是我輸入了指令:git add 。如下面所示:
這時(shí)并沒有提交更改到暫存區(qū),也就是提交沒有結(jié)束,若想將修改提交到gitlab上,需要繼續(xù)輸入指令:git commit -a -m “描述”。然后緊接著輸入git push指令。才能將修改提交上去。
但是我并不想提交這次修改,所以可以采用下面的指令:
git restore
將在工作區(qū)但不在暫存區(qū)的文件撤銷修改,文件的內(nèi)容恢復(fù)到?jīng)]有修改之前。就是將本地這一次不應(yīng)該上傳已經(jīng)的文件撤銷,但是可以看到還是有一些文件的狀態(tài)還是不怎么正常。
緊接著執(zhí)行指令:
先將文件ZhuShouMainFrame.pro.user.546ac14合并,之后更新了代碼,然后又查看了文件的狀態(tài),可以看到還是有文件狀態(tài)不怎么看著舒服,接著輸入下面的指令。
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上面的提示指出可以通過忽略本次文件在工作區(qū)的更改,于是我就忽略了。輸入指令:
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.經(jīng)過一頓亂操作,可以看到現(xiàn)在查看代碼的狀態(tài)的時(shí)候是正常的狀態(tài),看著順眼了。
作者也是第一次使用gitlab很多不懂,還望指教。
總結(jié)
1.git restore
撤銷本次在工作區(qū)但是沒有在暫存區(qū)的文件內(nèi)容的更改。
2.git restore --staged
將暫存區(qū)的文件從暫存區(qū)撤出,不改變文件的內(nèi)容。
總結(jié)
以上是生活随笔為你收集整理的git status查看文件的状态的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gbase迁移mysql_基于datax
- 下一篇: bootstrap table移动端_b