[INFO] GIT commands

Since TrinityCore moved to git, I think this commands will be useful for all users. If you have some interesting commands, tricks or solutions for non-standard tasks - please, share.

Download sources:

git clone git://github.com/TrinityCore/TrinityCore.gitDownload sources in custom folder:

git clone git://github.com/TrinityCore/TrinityCore.git <folder_name>Update sources for up-to-date version:

git pull origin masterShow all branches (local + remote):

git branch -aDownload sources from specific branch:

[CODE]git clone git://github.com/TrinityCore/TrinityCore.git

git checkout -b origin/<remote_branch>[/CODE]Create new branch:

git branch <branch>Show current branch:

git branchSwitch branch:

git checkout <branch>Show modifications - usually used when you commit something to your repo:

git statusShow differences between two branches:

[CODE]git diff <branch_1>…<branch_2>

git diff master…

git diff (diff with master)[/CODE]Create patch from modified sources:

git diff > <patch_name>.patchCreate patch from different branches:

[CODE]git diff master -p > <patch_name>.patch

git diff master > <patch_name>.patch[/CODE]Create patch from different commits:

[CODE]git diff <commit_hash_1> <commit_hash_2> > <patch_name>.patch

git diff 719ffeb414c97e09469b 52cd2cbd7eb62648ae13 > <patch_name>.patch[/CODE]Apply patch to sources:

git apply < <patch_name>.patchApply patch to sources with creating of new files:

patch -p1 < <patch_name>.patchRevert applied patch:

patch -p1 -R < <patch_name>.patchAdd all modifications to sources:

git add *Add single modifications to sources:

git add <file_name>Create commit:

git commit -a -m "<description>"Create commit with author:

git commit --author="name <[email protected]>" -m "<description>"Show log changes:

[CODE]git log

git log --format=oneline[/CODE]Advanced log view:

[CODE]git log --oneline --author/commiter=

git log --since/after/before/until=

git log --pretty=format:

git log --summary

git log --stat

git log --help[/CODE]Revert all changes in source code:

git reset --hardRemove all except original source files:

git clean -f -x -dSwitch to master branch:

git checkout masterDelete specific branch:

git branch <branch> -DDownload specific revision of sources (for example 10 revisions below):

[CODE]git clone git://github.com/TrinityCore/TrinityCore.git

cd ./TrinityCore

git checkout master

git reset HEAD~10[/CODE]Switch to specific revision 1. Find commit’s hash for specific revision:

git log --grep=Core/DBLayer2. Find needed commit’s hash. Like this one:

[CODE]…

commit 70a45be1594c43e09f7103c910f11a0476f88b52

…[/CODE]3. Revert to specific revision with creation of new branch “DBLayer”:

git checkout -b DBLayer 70a45be1594c43e09f7103c910f11a0476f88b52Undo last push to your remote repository:

git push -f origin HEAD^:masteror

[CODE]git rebase -i origin/~1

git rebase --abort

git push origin +

vim → delete everything and type: noop[/CODE]Get all commits from specific one like patch files:

git format-patch --full-index 52499b03ea8c86ab536c2025c3629b8883f591f2Get cherry-pick patch from remote repository:

git log --reverse --pretty=tformat:'git cherry-pick %h # %s' | grep "\[patch"Merge remote branch to your repository:

[CODE]git clone [email protected]:/TrinityCore.git <folder_name>

cd ./<folder_name>

git remote add -f -t master -m master upstream <remote_repository>

git merge upstream/master[/CODE]Download remote fork to local repository:

[CODE]git remote add upstream git://github.com//TrinityCore.git

git fetch upstream

git checkout -b upstream/<remote_branch>

git pull upstream <remote_branch>[/CODE]
Credits goes to ru-mangos community, google and github help topics =]

plz help me - delete & remove commit

Please Add more commnad that we need on special cases like conflicts, how to resolve them etc

[B][Guide] Fixing “Patch Does Not Apply” Errors[/B]

Use patch command under linux/win and find blocks in ur code (with npp or other editor):


<<<<<<< HEAD

								 uiDeathArmyCheckTimer = 0;

								 bDeathArmyDone = true;

=======

								 if (uiDeathArmyCheckTimer <= uiDiff)

								 {

									 me->ClearUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED);

									 uiDeathArmyCheckTimer = 0;

									 bDeathArmyDone = true;

								 } else uiDeathArmyCheckTimer -= uiDiff;

>>>>>>> 84268be882e79ee7633323502ce83f2e4bfcf3a9

all between <<<<<<< HEAD and ======= - is what u have now in code, between ======= and >>>>>>> [hash] - what u want to have, after apply patch or smth. Check logic, functions, variables, etc and try to fix ur code. There is no step-by-step guide “how to fix conflicts after applyin patch”.

TortoiseGIT guide moved back into its own topic for easier seaching / discussion until I can put it on the wiki. It shouldn’t have been merged into the middle of a discussion about the commandline.

Epic guide!

Thank you very much /emoticons/default_smile.png

[LEFT][/LEFT]

git revert <hash>

example:

[LEFT][/LEFT]

[SIZE=12px][FONT=Verdana]git revert ca9918e[/FONT][/SIZE]

Learn git in 15 minutes /emoticons/default_wink.png

rly simple and easy way to learn git, just try out yourself!

A bit more online guides and how-tos:

http://rogerdudler.github.com/git-guide/

http://githowto.com/making_changes

Rly interesting thing from Peter Cottle for those who wants to know more about GIT branchin:

https://pcottle.github.io/learnGitBranching/assets/learnGitBranching.png

http://pcottle.github.com/learnGitBranching/

Supported commands:

[ul]
[li]commit[/li][li]branch[/li][li]checkout[/li][li]cherry-pick[/li][li]reset[/li][li]revert[/li][li]rebase[/li][li]merge[/li][/ul]

For those who want to have quick start with GIT:

GitHub Cheat Sheet

[COLOR=rgb(51,51,51)]All the hidden and not hidden features of Git and GitHub. This cheat sheet was inspired by Zach Holman[COLOR=rgb(51,51,51)]'s Git and GitHub Secrets[COLOR=rgb(51,51,51)] talk at Aloha Ruby Conference 2012 (slides[COLOR=rgb(51,51,51)]) and his More Git and GitHub Secrets[COLOR=rgb(51,51,51)] talk at WDCNZ 2013 (slides[COLOR=rgb(51,51,51)]).

[SIZE=15px]Link: https://github.com/tiimgreen/github-cheat-sheet[/SIZE]