_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN
Let's talk

Git: jak opravit (skoro) každou chybu

11. 05. 2017 1 min read intermediate

Udělali jste chybu v Gitu? Klid — Git skoro nikdy nic nesmaže definitivně.

Commit do špatné větve

git branch correct-branch
git reset –hard HEAD~1
git checkout correct-branch

Změna commit message

git commit –amend -m “nová zpráva”

Zapomenutý soubor

git add forgotten.py
git commit –amend –no-edit

Vrátit commit

git reset –soft HEAD~1

Smazaná branch

git reflog
git checkout -b recovered abc1234

Merge conflict

git status

vyřešte konflikty

git add resolved.py
git commit

Revert pushnutého commitu

git revert abc1234

Ztracené změny po hard reset

git reflog
git branch recovery HEAD@{2}

Ignorovat trackovaný soubor

git rm –cached config.local.yml
echo “config.local.yml” >> .gitignore

Zlaté pravidlo

Git reflog je záchranná síť. Dokud neprobíhá gc, vaše data tam jsou.

gittroubleshooting
Share:

CORE SYSTEMS tým

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.