SORU
1 HAZİRAN 2009, PAZARTESİ


Git bazı dosyaları değişiklikleri geri al

Ekledim kodlama yaparken bazı dosyaları ne olup bittiğini takip etmek için içine tabloları yazdırın.

İşim bittiğinde, bazı dosyaları değişiklikleri geri alma, ama dosyayı işlemek için mümkün ben gerçekten çalıştı mı?

A ama değiştirilmiş bir dosya B Dosya Yazdır ekledim diyelim. B işlemek istiyorum ve A eski durumuna geri olmak istiyorum.

CEVAP
1 HAZİRAN 2009, PAZARTESİ


Üç temel yolu vardır bunu yapmak için bağlı olarak yaptığınız değişiklikleri dosya A. Eğer Henüz eklenen değişiklikler için dizin veya işlenen onları, sonra sadece kullanmak için çıkış komutu - bu değişecek devletin çalışma kopyası için maç deposu:

git checkout A

Eğer dizin için zaten eklediniz, reset kullanın:

git reset A

Eğer taahhüt varsa, o zaman Geri Al komutunu kullanın:

# the -n means, do not commit the revert yet
git revert -n <sha1>
# now make sure we are just going to commit the revert to A
git reset B
git commit

Eğer diğer taraftan, vardı işlenirse, ama taahhüt işin içinde daha fazlası var dosyaları değil, aynı zamanda döner ve yukarıdaki yöntem olabilir dahil bir çok "reset B" komutları. Bu durumda, bu yöntemi kullanmak isteyebilirsiniz:

# revert, but do not commit yet
git revert -n <sha1>
# clean all the changes from the index
git reset
# now just add A
git add A
git commit

Başka bir yöntem yine,- ben rebase komutu kullanılması gerekir. Bunu düzenlemek için bir taahhüt daha yararlı olabilir:

# use rebase -i to cherry pick the commit you want to edit
# specify the sha1 of the commit before the one you want to edit
# you get an editor with a file and a bunch of lines starting with "pick"
# change the one(s) you want to edit to "edit" and then save the file
git rebase -i <sha1>
# now you enter a loop, for each commit you set as "edit", you get to basically redo that commit from scratch
# assume we just picked the one commit with the erroneous A commit
git reset A
git commit --amend
# go back to the start of the loop
git rebase --continue

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • KIT KAT

    KIT KAT

    3 EKİM 2005
  • Michael Neal

    Michael Neal

    2 Mayıs 2009
  • PhoneArena

    PhoneArena

    7 NİSAN 2006