Git teams that can break / rewrite history

Can you provide a list of (all or the most common) operations or commands that might compromise history in git?

What should i avoid?

  • Change commit after pressing this button ( git commit/ git push/ git commit --amend)
  • Climb to what has already been pressed

I would like this question (if it has not yet been asked elsewhere) to become a kind of reference to general preventable operations on git .

In addition, I use a lot git reset, but do not fully understand the possible damage that I could do in the repository (or in other copies of the authors). Could it git resetbe dangerous?

+6
source share
4 answers

knittl has already put together a good list of teams that rewrite history, but I would like to build on his answer.

Can you provide a list of [...] operations or commands that could jeopardize the story in git? What should i avoid?

First of all, there is nothing wrong with rewriting / deleting a story as such; in the end, you probably regularly create function branches, keep them strictly local, and then delete them (after merging them or realize that they don't lead anywhere) without thinking about it twice.

However, you can and, of course, run into problems when rewriting / deleting a history locally that other people already have access to, and then press it on the shared remote.

, /

, (, .git/objects/), .

. Pro Git, ,

  • git amend --commit
  • git rebase
  • git filter-branch
  • Roberto Tyley BFG Repo Cleaner ( )

, . , ( ) , , . :

  • git commit --amend: ;
  • rebase ( git pull --rebase);
  • git reset (. );
  • git checkout -B git branch -f: ;
  • git tag --force: , .

( ) :

  • git branch -d git branch -d
  • git tag -d

, , , , .

. , , Git, .

, /

, git push -f ( git push --force) / .

,

  • , receive.denyNonFastForwards .
  • , , receive.denyDeletes .

, git reset, , ( ). git reset ?

git-reset, knittl, , . , . , :

enter image description here

master, commit D. , , ,

git reset master~2

reset reset, "" , , . , , , : reset

enter image description here

C D, master reset, ; , - (, HEAD). , " limbo"; Git, git log.

, reset, , (, ) D . C D Git .

D reflog, , , reflog commit D.

, , git-reset , , , , reset, reset. reset, , ; , , .

+4

:

  • git commit --amend
  • git rebase (rebase git pull --rebase branch.$name.rebase)
  • git filter-branch
  • git push -f ( git push origin +branch)
  • git reset
  • git branch -f ( )
  • git checkout -B ( )
+6

git push -f mirror

, , , .

+2

, Git 2.24 (Q4 2019), git filter-branch.

git filter-branch (BFG )

. commit 483e861, commit 9df53c5, commit 7b6ad97 (04 2019 .) (newren).
(Merged by Junio C Hamano -- [TG43] -- in commit 91243b0, 30 Sep 2019)

git-filter-repo git-filter-branch

filter-branch , (.. ).

.
, , , , , filter-branch, . , filter-branch, man- (, filter-repo).

, filter-branch.
, filter-branch, - , filter-branch (, BFG, reposurgeon, fast-import, filter-repo), - filter-branch , .
, filter-branch.

, , BFG Repo Cleaner filter-branch.
- , , , BFG, filter-repo ( , filter-branch), :

  • filter-branch, - , .
    , filter-repo . .
  • , , ; , , - , .
  • BFG filter-repo
  • , BFG, filter-repo .
    , filter-repo BFG bfg-ish, , BFG, , BFG - ,

, , - , , filter-repo , BFG, , .


, git?

, newren/git-filter-repo , .

:

. , .

, - , , - .
, , , --force.


git filter-repo, , :

git fast-export <options> | filter | git fast-import <options>

git fast-export/git fast-import git 2.24 (Q4 2019)

. commit 941790d, commit 8d7d33c, commit a1638cf, commit 208d692, commit b8f50e5, commit f73b2ab, 3164e6b (03 2019 .) af2abd8 (25 2019 .) (newren) ..
(Merged by Junio C Hamano -- [TG443] -- in commit 16d9d71, 15 Oct 2019)

:

fast-import:

Signed-off-by: Elijah Newren

fast-export fast-import .

BLOB- , , , , .

, , , :

  1. , ( ).
  2. , --export-marks --import-marks.

, .

+1

All Articles