wie man nach einem schlechten Trottel zurückgeht

1124
debamitro

Ich hatte einen flachen Klon eines riesigen Repository erstellt (um Zeit zu sparen)

Git-Klon - Tiefe = 1 ...

Einige Tage später dachte ich, ich würde die neuesten Commits aus dem Remote-Repository holen. ich betrat

git ziehen

Aber es fing an, mehr Informationen herunterzuladen, als ich an erster Stelle hatte (mein anfänglicher flacher Klon war ~ 150 MB und hier war der Pull bereits mehr als 100 MB und zeigte 22%). Also drückte ich Ctrl-C und stoppte sie. Danach habe ich versucht (nur zufällig)

Git Pull - Tiefe = 1

und das hat viele Fehler aufgeworfen. Und jetzt bin ich mit einem lokalen Repository übrig, in dem git status sagt:

# On branch master # Your branch and 'origin/master' have diverged, # and have 3 and 4 different commits each, respectively. # 

Gibt es eine Möglichkeit, die Dinge richtig zu stellen, abgesehen von der Erstellung eines neuen flachen Klons? Ich habe keine eigenen Verpflichtungen, also ist alles cool.

0

3 Antworten auf die Frage

1
malgca

When you clone a repo with git, you get the repo's full history, from the first commit to the last, however, since you made a shallow clone, you only have the history depth that you specified.

If you know which commit you want to go back to, you could try git reset --hard _commit_ to revert your HEAD, the Index and the contents of your working directory to what they were in that specific commit (the first one, in this case).

If you don't remember which one it is, just use git log to check through the commits for the one you're looking for.

git log  commit c09ea7f2a7f01921fda4ee0b53934cba42fb9ee3 Author: That guy Date: The other day  This was your first commit 

Remember that you only need the first few characters of the commit ID to reset so using:

git reset --hard c09ea7f2a7f019 

Should be enough to identify the commit as unique and reset your HEAD, Index and directory contents to how they were in that commit.

1
Satabdi

You can also do a

git pull --rebase --depth=1 

This will try to rebase your local changes after the pull (although you haven't done anything but git thinks you have). And then git should tell you that there are conflicts because it will find the same changes in the files. Then you can just simply do a -

git rebase --skip 

i.e. you are asking git not to apply your local changes. It should fix your problem.

Nun, nachdem ich diesen 'git status' in meinem lokalen Repository durchgeführt habe, zeigt sich, dass alles auf dem neuesten Stand ist, aber wenn ich vom Remote-Repository aus über das Web überprüfe, kann ich feststellen, dass ich nicht die neuesten Commits habe. Was als nächstes? debamitro vor 11 Jahren 0
0
bain
# delete local master and checkout remote git branch -D master git checkout master # clean up any objects left by your interrupted pull git prune git gc