日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

git status查看文件的状态

發布時間:2024/9/27 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 。如下面所示:

dhusd@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git add SceneModule/SceneComponent/layoutListwidget.cppbanli@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git pull error: Your local changes to the following files would be overwritten by merge:SceneModule/SceneComponent/layoutListwidget.cpp Please commit your changes or stash them before you merge. error: Your local changes to the following files would be overwritten by merge:ZhuShouMainFrame.pro.user Please commit your changes or stash them before you merge. error: The following untracked working tree files would be overwritten by merge:ZhuShouMainFrame.pro.user.546ac14 Please move or remove them before you merge. Aborting Updating 77e467a..e1727c0

這時并沒有提交更改到暫存區,也就是提交沒有結束,若想將修改提交到gitlab上,需要繼續輸入指令:git commit -a -m “描述”。然后緊接著輸入git push指令。才能將修改提交上去。
但是我并不想提交這次修改,所以可以采用下面的指令:
git restore

sdsf@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git restore ZhuShouMainFrame.pro.usersdsf@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git pull error: Your local changes to the following files would be overwritten by merge:SceneModule/SceneComponent/layoutListwidget.cpp Please commit your changes or stash them before you merge. error: The following untracked working tree files would be overwritten by merge:ZhuShouMainFrame.pro.user.546ac14 Please move or remove them before you merge. Aborting Updating 77e467a..e1727c0sdsf@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)modified: SceneModule/SceneComponent/layoutListwidget.cppUntracked files:(use "git add <file>..." to include in what will be committed)ZhuShouMainFrame.pro.user.546ac14

將在工作區但不在暫存區的文件撤銷修改,文件的內容恢復到沒有修改之前。就是將本地這一次不應該上傳已經的文件撤銷,但是可以看到還是有一些文件的狀態還是不怎么正常。
緊接著執行指令:

sdcs@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git add ZhuShouMainFrame.pro.user.546ac14sdcs@DESKTOP-2DAKPIL MINGW64 /g/excise/zhushouProject/ZhuShou (master) $ git pull error: Your local changes to the following files would be overwritten by merge:SceneModule/SceneComponent/layoutListwidget.cpp Please commit your changes or stash them before you merge. Aborting Updating 77e467a..e1727c0sdcs@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)modified: SceneModule/SceneComponent/layoutListwidget.cppnew file: ZhuShouMainFrame.pro.user.546ac14

先將文件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查看文件的状态的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。