git刪除遠程倉庫文件


1 首先將遠程代碼pull到本地,保持本地倉庫跟遠端倉庫同步

git pull git@github.com:lanleilin/lanGallery.git//使用SSH的方式

2 然后使用git rm命令刪掉要刪除的文件

git rm readme.md

3 刪除之后,本地目錄下已經刪除的文件夾就不再存在了,為了能將遠程倉庫的相應文件也刪除掉,我們要把這次操作提交到上去

git commit -m "remove markdown"

4然后將更改push到遠程

git push

 

其他git方法:

1 git 刪除和版本回退:

 

首先刪除: git rm '*' //刪除全部

然后git log 查看版本日志

然后git reset --hard 123456回到具體版本

git刪除文件夾以及其目錄下文件:git rm myJs -r -f

 

2 遠程強制回到某版本:

先reset到某版本,然后

git push -f

 

 3 git中出現 Please enter a commit message to explain why this merge is necessary.

                git 在pull或者合並分支的時候有時會遇到這個界面。可以不管(直接下面3,4步),如果要輸入解釋的話就需要:

                            1.按鍵盤字母 i 進入insert模式

                            2.修改最上面那行黃色合並信息,可以不修改

                            3.按鍵盤左上角"Esc"

                            4.輸入":wq",注意是冒號+wq,按回車鍵即可

4 pull request操作

> git checkout -b survey           # 在本地創建 survey 分支,並切換到分支 survey
> git add *                 # 添加修改
> git commit -m " modified *** file" # 本地提交

> git push origin survey            # 在origin (遠)端,創建survey 分支,並將本地的survey 分支內容 push 到遠端的 origin/survey分支
> git branch -a                       # (非必要命令)查看遠端分支創建是否成功

然后在網頁端開啟pull request請求合並分支

 刪除分支:git branch -D survey

5 解決沖突

  指定本地dev分支與遠程origin/dev分支的鏈接    

  $ git branch --set-upstream dev origin/dev

  $ git pull
  
  $git status 查看沖突,刪除沖突文件 重新提交
  $ git add readme.txt   $ git commit -m "conflict fixed"
 

https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013760174128707b935b0be6fc4fc6ace66c4f15618f8d000


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM