LPS:GIT

Z HelpDesk

Návody jak řešit problémové situace v GITu:

Řešení konfliktů

přes 'git add' a 'git commit -am "message"'

Pokud se při git merge <branch> ukáže např.:

# git merge iptables
Auto-merging templates/etc/iptables/rules.v4
CONFLICT (content): Merge conflict in templates/etc/iptables/rules.v4
Automatic merge failed; fix conflicts and then commit the result.

A git status ukazuje:

# git status
# On branch production
# Your branch is up-to-date with 'origin/production'.
#
# You have unmerged paths.
#   (fix conflicts and run "git commit")
#
# Unmerged paths:
#   (use "git add <file>..." to mark resolution)
#
#       both modified:      rules.v4
#
no changes added to commit (use "git add" and/or "git commit -a")

Potom git diff [soubor] ukáže problém:

# git diff
diff --cc templates/etc/iptables/rules.v4
index 91dcee0,1bbbe72..0000000
--- a/templates/etc/iptables/rules.v4
+++ b/templates/etc/iptables/rules.v4
@@@ -60,6 -60,12 +60,15 @@@ COMMI
  -A SHELL -s 147.228.58.32/32 -p tcp -m tcp --dport 22 -j ACCEPT -m comment --comment "Zalohovani ze salvator.zcu.cz"
  [%CFEngine webkdc2_zcu_cz:: %]
  -A SHELL -s 147.228.54.61/32 -p tcp -m tcp --dport 22 -j ACCEPT -m comment --comment "prijem webkdc klice z webkdc1.zcu.cz"
++<<<<<<< HEAD
++=======
+ [%CFEngine group_moodle:: %]
+ -A SHELL -s 147.228.54.32/32 -p tcp -m tcp --dport 22 -j ACCEPT -m comment --comment "danaus.zcu.cz pro ldapmgr"
+ -A SHELL -s 147.228.4.46/32 -p tcp -m tcp --dport 22 -j ACCEPT -m comment --comment "phix-old.zcu.cz"
+ [%CFEngine phix_test_zcu_cz:: %]
+ -A SHELL -s 147.228.53.15/32 -p tcp -m tcp --dport 22 -j ACCEPT -m comment --comment "eryx1.zcu.cz"
+ -A SHELL -s 147.228.53.16/32 -p tcp -m tcp --dport 22 -j ACCEPT -m comment --comment "eryx2.zcu.cz"
++>>>>>>> iptables
  
  [%CFEngine any:: %]
  [%CFEngine BEGIN %]

To samé je vidět přímo v souboru ve kterém odstraníme značku a tu část, kterou nechceme, do jiné části nezasahovat. Výsledek si lze zkontrolovat přes git diff [soubor], následně přidat soubor:

# git add rules.v4

Na závěr se commitnou všechny čekající změny z informativním hlášením:

# git commit -am "Vyreseni konfliktu"
[production acc3c0a] Vyreseni konfliktu
 Author: Ing. Michal SVAMBERG <svamberg@civ.zcu.cz>
 Committer: root <root@orion.zcu.cz>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

A tím je hotovo.