国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語(yǔ)言|JavaScript|易語(yǔ)言|vb.net|

服務(wù)器之家 - 編程語(yǔ)言 - 編程技術(shù) - 解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解

解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解

2020-08-29 16:54CodeMissing 編程技術(shù)

這篇文章主要介紹了解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

解決這個(gè)問(wèn)題并沒(méi)有特別的(刪除提交歷史中某個(gè)文件,然后重新push),但是由于開(kāi)始的使用失誤,中間有使用git rebasegit reset命令處理,所以特此記錄下

大文件無(wú)法push到遠(yuǎn)程倉(cāng)庫(kù)

問(wèn)題

首先,故事(事故)的起因是這樣的。

某次git push(類似測(cè)試使用,沒(méi)有分支)到遠(yuǎn)程倉(cāng)庫(kù)時(shí)發(fā)生如下無(wú)法提交大文件的報(bào)錯(cuò)(大文件是一個(gè)pdf文件)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ git push
enumerating objects: 204, done.
counting objects: 100% (204/204), done.
delta compression using up to 4 threads
compressing objects: 100% (183/183), done.
writing objects: 100% (187/187), 419.00 mib | 2.21 mib/s, done.
total 187 (delta 21), reused 0 (delta 0)
remote: resolving deltas: 100% (21/21), completed with 12 local objects.
remote: powered by gitee.com [gnk-3.8]
remote: error: file: db501995ac30070d50bdc115a7708f9ba84332d3 403.57 mb, exceeds 100.00 mb.
remote: use command below to see the filename:
remote: git rev-list --objects --all | grep db501995ac30070d50bdc115a7708f9ba84332d3
remote: please remove the file from history and try again. (https://gitee.com/help/articles/4232)
to gitee.com:findmoon/xxxx.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitee.com:findmoon/xxxx.git'

根據(jù)提示,如下查看大文件是哪個(gè)

解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解

commit的大文件無(wú)法push到遠(yuǎn)程庫(kù)解決辦法

首先說(shuō)一下解決辦法,需要修改提交歷史,刪除已提交到本地倉(cāng)庫(kù)的大文件的提交記錄,

從commit的提交歷史中刪除指定文件的命令為git filter-branch --tree-filter 'rm -f 文件名' head

如下,刪除大文件

?
1
2
3
$ git filter-branch --tree-filter 'rm -f "electron/pdf/677969 xxxx xxx.pdf"' head
rewrite d1244f8fbc1f08b473bd498c023b09bd8ac3246b (12/12) (156 seconds passed, remaining 0 predicted)
ref 'refs/heads/master' was rewritten

執(zhí)行刪除成功會(huì)返回ref 'refs/heads/master' was rewritten提示,如果返回unchanged則表示沒(méi)有任何更改。

如果文件路徑包含空格需要用引號(hào)將刪除文件路徑包含起來(lái)。

然后重新push推送成功。

整體操作如下:

解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解

git filter-branch命令:

解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解

參考自git誤commit大文件導(dǎo)致不能push問(wèn)題解決

git commit后的回滾

撤銷已經(jīng)提交的commit有兩種方法:

使用 git reset --hard head^

使用 git rebase -i head~n

git reset --hard 丟棄最新的提交

代碼提交后,需求發(fā)生變化導(dǎo)致之前提交的已經(jīng)不合適,或者 代碼提交后發(fā)現(xiàn)有嚴(yán)重bug,需要回滾可是使用這個(gè)命令:

git reset --hard head^

1,head^ 表示 最新提交head位置往回?cái)?shù)一個(gè)提交, 幾個(gè) ^ 就往回?cái)?shù)幾個(gè)提交;

2,head~n 表示 最新提交head位置往回?cái)?shù)n個(gè)提交

reset 命令只能回滾最新的提交。如果只想刪除指定的某個(gè)提交,而保留最新的一次或兩次commit,reset就無(wú)法做到了。

reset命令 git 刪除某次指定的提交

git rebase -i 丟棄指定提交

如果想撤銷中間某次commit的情況,可以使用如下的命令:

git rebase -i head~2(列出最新的兩次提交,然后決定對(duì)應(yīng)提交的操作)

rebase -irebase --interactive 的縮寫;

git rebase -i 不僅可以刪除commit, 還可以修改commit。 具體的可以查看rebase中提示的參數(shù)

如下執(zhí)行git rebase查看命令參數(shù):

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$ git rebase -i head~2
pick 71add05 20200225同步
pick 45d4805 測(cè)試刪除中間某次commit
 
# rebase 36b460a..45d4805 onto 36b460a (2 commands)
#
# commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current head with a name
# t, reset <label> = reset head to a label
# m, merge [-c <commit> | -c <commit>] <label> [# <oneline>]
# .    create a merge commit using the original merge commit's
# .    message (or the oneline, if no original merge commit was
# .    specified). use -c <commit> to reword the commit message.
#
# these lines can be re-ordered; they are executed from top to bottom.
#
# if you remove a line here that commit will be lost.
#
# however, if you remove everything, the rebase will be aborted.
#
# note that empty commits are commented out

常用的如下:

  • edit: 使用本次提交,在rebase到這次提交時(shí)候,會(huì)暫停下來(lái)等待修正
  • pick:使用本次提交,不操作修改
  • drop:刪除這次提交

如下,修改查看最近3次的提交,然后刪除(drop)倒數(shù)第三次commit,保存退出即可將倒數(shù)第三次commit中提交的所有內(nèi)容刪除

解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解

回滾最新的提交 :git resetgit rebase 命令都可以

回滾中間某次提交: git rebase 可以, git reset 不可以

如果提交已經(jīng)同步到遠(yuǎn)程倉(cāng)庫(kù),需要使用git push origin -f branch(分支名) 來(lái)將回滾也同步到遠(yuǎn)程倉(cāng)庫(kù)(master 分支謹(jǐn)慎使用 -f)

主要參考自

git rebase

git rebase執(zhí)行失敗后的退出

像上面,執(zhí)行git rebase有可能導(dǎo)致失敗,具體表現(xiàn)為bash中的倉(cāng)庫(kù)標(biāo)識(shí)變?yōu)榱?code>(master|rebase 1/10)(m/n視r(shí)eabse編輯內(nèi)容而定)

解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解

解決辦法是:執(zhí)行git rebase --abort即可退出這個(gè)錯(cuò)誤,回退到當(dāng)前分支中,且數(shù)據(jù)和文件也都能恢復(fù)。

不小心git rebase后出現(xiàn)(master|rebase 1/10)的解決辦法

git rebase成功后的回退

上面講的是git rebase失敗后的退出(,或回退),如果成功刪除了某次commit,導(dǎo)致最終一些文件或數(shù)據(jù)丟失,如何恢復(fù)呢?

不要輕易使用 git rebase -i head 刪除某次提交

git rebase -i head~2中刪除某次提交的話,這次提交的所有更改和新增文件會(huì)全部取消,覆蓋本地工作目錄中的文件,也就是刪除的這次提交和本次提交的上一次提交中間的所有更改都會(huì)取消,即使pick了刪除提交的下一次提交,也無(wú)法保留(保留到最新提交時(shí)所有文件和文件夾的狀態(tài))

可以使用git reset --hard id命令,直接恢復(fù)commit到指定的提交時(shí)刻。

git reflog查看git提交記錄

解決使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)問(wèn)題及git rebase使用詳解

如上,可以直接看到需要恢復(fù)到的commit id是多少。比如恢復(fù)到id為71add05的時(shí)刻,執(zhí)行git reset --hard 71add05等待恢復(fù)。本地倉(cāng)庫(kù)和文件就能恢復(fù)到指定提交時(shí)刻。

恢復(fù)指定的某次commit成功。

 

 

刪除文件后需要執(zhí)行git add -agit rm <file>,將刪除添加到暫存區(qū), 如果執(zhí)行 git add. 是不行的,區(qū)別如下:

git add -a 保存所有的修改(包括刪除的文件、新增文件、已有文件的修改變更)git add . 保存新的添加和修改,但是不包括刪除git add -u 保存修改和刪除,但是不包括新建文件。

到此這篇關(guān)于記一次使用commit提交大文件無(wú)法推送到遠(yuǎn)程庫(kù)解決問(wèn)題過(guò)程及git rebase使用的文章就介紹到這了,更多相關(guān)commit提交大文件git rebase使用內(nèi)容請(qǐng)搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://www.cnblogs.com/codemissing/p/git_push_bigfile_issue.html

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 欧美一区视频 | 精品女同一区二区三区在线绯色 | 91超碰在线观看 | caoporn最新地址| 欧美日韩一区二区在线 | 韩日在线观看视频 | 国产一区久久 | 一区二区三区四区在线视频 | 日韩精品影院 | 色婷婷精品国产一区二区三区 | 操av网 | 在线小视频 | 久久精品播放 | 久久久久久久久久久久久久av | 久久久精品日韩 | 国产精品毛片久久久久久 | 精品国产一区二区在线 | 国产精品免费一区二区三区四区 | 欧美日韩中文 | 亚洲日本va中文字幕 | 欧洲一区 | 久久精品中文字幕 | 欧美亚洲综合久久 | 在线播放一级片 | 欧美视频精品在线观看 | 欧美精品在线一区二区三区 | 欧美亚洲综合久久 | 538在线精品 | 亚洲国内精品 | 一区在线视频 | 一区二区三区在线观看视频 | 日韩不卡| 欧洲一级毛片 | 日韩精品小视频 | 免费在线亚洲 | 午夜午夜精品一区二区三区文 | 男人天堂社区 | 欧美日韩在线综合 | 国产精品亚洲第一区在线暖暖韩国 | 日本免费在线视频 | 日本久久网 |