29.06.2024

0

Like

55

Views

Git Hata Mesajları Notları

Git ile uğraşırken, pek çok kişinin aynı benim gibi Git’in hata mesajlarıyla sorun yaşadığını ettiğini fark ettim. Bu hata mesajlarıyla ben de çok boğuştum ve şunu fark ettim:

Bazen hata mesajları gerçekten kafamı karıştırıyor. Fakat sanırım kafamın karışmasına alıştım.
Git'in bana verdiği hata mesajı çok bilgilendirici olmadığında daha fazla bilgi almak için bir dizi strateji geliştirdim.

Bu yüzden bu yazıda Git'in hata mesajlarından birkaçını inceleyeceğim. Her biri için kafa karıştırıcı olduğunu düşündüğüm birkaç şeyi açıklayıp kafam karıştığında ne yaptığımdan da bahsedeceğim.

error: git push on a diverged branch


$ git push
To github.com:jvns/int-exposed
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'github.com:jvns/int-exposed'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

$ git status
On branch main
Your branch and 'origin/main' have diverged,
and have 2 and 1 different commits each, respectively.


Durumu anlamak için git status veya git pull çalıştırmak gerekir. Durumu anlamak için git status kullanın ve genellikle tek bir branch push ettiğiniz için hangi branch'in reddedildiğiyle ilgili notlarla kafanızı karıştırmayın.


error: git pull on a diverged branch


$ git pull
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint: git config pull.rebase false # merge
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.


Pull komutunda fazla seçenek sunulması (örneğin, pull.rebase false/true ve pull.ff only) yeni başlayanlar için karmaşık olabilir. Durumu görmek için git status çalıştırın, git log origin/main veya git log ile ayrılan commit'leri gözden geçirin, genellikle git pull --rebase kullanarak çözüm bulunuyor.


error: git checkout asdf (a branch that doesn't exist)


$ git checkout asdf
error: pathspec 'asdf' did not match any file(s) known to git


Hata mesajı, var olmayan bir pathspeci belirtiyor gibi görünüyor. Git switch kullanmayı düşünebilirsiniz. Ancak genellikle git checkout kullanıyorum.

git switch asdf (a branch that doesn't exist)


$ git switch asdf
fatal: invalid reference: asdf


"Invalid reference: asdf" mesajı, asdf'nin bir branch olmadığını belirtiyor. Git switch'in yalnızca branch kabul ettiğini unutmayın ve hata mesajında geçen "reference" yerine "branch" kelimesini düşünün.


error: git checkout HEAD^


$ git checkout HEAD^
Note: switching to 'HEAD^'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

git switch -c

Or undo this operation with:

git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 182cd3f add "swap byte order" button


Detached HEAD durumunda olduğunuzu belirten mesaj yeni başlayanlar için anlaşılması zor olabilir. Shell promptunuzda detached HEAD durumunun belirtilmesini unutmayın ve işiniz bitince git checkout main gibi bir komutla branch'e geri dönün.


message: git status when a rebase is in progress


$ git status
interactive rebase in progress; onto c694cf8
Last command done (1 command done):
pick 0a9964d wip
No commands remaining.
You are currently rebasing branch 'main' on 'c694cf8'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)

Unmerged paths:
(use "git restore --staged ..." to unstage)
(use "git add ..." to mark resolution)
both modified: index.html

no changes added to commit (use "git add" and/or "git commit -a")



Rebase sırasında hangi dalda olduğunuzun net olmadığı bir durum.Shell promptunuzun rebase işlemi sırasında hangi branch üzerinde olduğunuzu belirtmesine güvenebilirsiniz.


error: git status during a merge or rebase


$ git status
On branch master
You have unmerged paths.
(fix conflicts and run “git commit”)
(use “git merge –abort” to abort the merge)


Unmerged paths:
(use “git add/rm …” as appropriate to mark resolution)
deleted by them: the_file

no changes added to commit (use “git add” and/or “git commit -a”)


"Deleted by them" ifadesinin neyi ima ettiğinin duruma göre değişmesi oldukça kafa karıştıran bir durum. Yaptığınız işlemi hatırlamaya çalışın veya git show main --stat gibi komutlarla durumu kontrol edin.


error: git clean


$ git clean
fatal: clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean


-i, -n ve -f seçeneklerinin anlaşılması zor olabilir. Git clean komutunun belirtilen seçeneklere göre nasıl çalıştığını öğrenmek için araştırma yapın veya güvenli bir şekilde git clean -f veya git clean -i kullanın.


Bu ipuçları, Git'in hata mesajlarını daha iyi anlamanıza ve yönetmenize yardımcı olabilir. Başlangıçta karmaşık görünebilirler fakat pratik yaptıkça ve mesajların arkasındaki mantığı anladıkça inanın daha da rahat edeceksiniz. Umarım bu yazı size yardımcı olmuştur.

GIT
İleri Seviye GIT

Comments

You need to log in to be able to comment!

Taylan Bal

another boomer

Location

Sinop, TR

Education

Software Engineering - Igor Sikorsky Kyiv Polytechnic Institute

© 2021 Patika Dev

facebook
twitter
instagram
youtube
linkedin