Jump to content


NEW custom search, includes forums, wiki, github issues, TC sourcecode, irc logs, doxygen automated documentation; read more here
Photo

[INFO] GIT commands


  • Please log in to reply
10 replies to this topic

#1 killradio_1337

killradio_1337

    Advanced Member

  • Members
  • PipPipPip
  • 123 posts

Posted 27 January 2011 - 08:15 AM

*
POPULAR

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.git

Download sources in custom folder:
git clone git://github.com/TrinityCore/TrinityCore.git <folder_name>

Update sources for up-to-date version:
git pull origin master

Show all branches (local + remote):
git branch -a

Download sources from specific branch:
git clone git://github.com/TrinityCore/TrinityCore.git
git checkout -b <branch> origin/<remote_branch>

Create new branch:
git branch <branch>

Show current branch:
git branch

Switch branch:
git checkout <branch>

Show modifications - usually used when you commit something to your repo:
git status

Show differences between two branches:
git diff <branch_1>..<branch_2>
git diff master..<branch>
git diff <branch> (diff with master)

Create patch from modified sources:
git diff > <patch_name>.patch

Create patch from different branches:
git diff master <branch> -p > <patch_name>.patch
git diff master <branch> > <patch_name>.patch

Create patch from different commits:
git diff <commit_hash_1> <commit_hash_2> > <patch_name>.patch
git diff 719ffeb414c97e09469b 52cd2cbd7eb62648ae13 > <patch_name>.patch

Apply patch to sources:
git apply < <patch_name>.patch

Apply patch to sources with creating of new files:
patch -p1 < <patch_name>.patch

Revert applied patch:
patch -p1 -R < <patch_name>.patch

Add 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:
git log
git log --format=oneline

Advanced log view:
git log --oneline --author/commiter=<author>
git log --since/after/before/until=<date>
git log --pretty=format:<string>
git log --summary
git log --stat
git log --help

Revert all changes in source code:
git reset --hard

Remove all except original source files:
git clean -f -x -d

Switch to master branch:
git checkout master

Delete specific branch:
git branch <branch> -D

Download specific revision of sources (for example 10 revisions below):
git clone git://github.com/TrinityCore/TrinityCore.git
cd ./TrinityCore
git checkout master
git reset HEAD~10

Switch to specific revision
1. Find commit's hash for specific revision:
git log --grep=Core/DBLayer
2. Find needed commit's hash. Like this one:
...
commit 70a45be1594c43e09f7103c910f11a0476f88b52
...
3. Revert to specific revision with creation of new branch "DBLayer":
git checkout -b DBLayer 70a45be1594c43e09f7103c910f11a0476f88b52

Undo last push to your remote repository:
git push -f origin HEAD^:master
or
git rebase -i origin/<branch>~1
git rebase --abort
git push origin +<branch>
vim -> delete everything and type: noop

Get all commits from specific one like patch files:
git format-patch --full-index 52499b03ea8c86ab536c2025c3629b8883f591f2

Get cherry-pick patch from remote repository:
git log --reverse --pretty=tformat:'git cherry-pick %h # %s' | grep "\[patch"

Merge remote branch to your repository:
git clone [email protected]:<username>/TrinityCore.git <folder_name>
cd ./<folder_name>
git remote add -f -t master -m master upstream <remote_repository>
git merge upstream/master

Download remote fork to local repository:
git remote add upstream git://github.com/<username>/TrinityCore.git
git fetch upstream
git checkout -b <branch> upstream/<remote_branch>
git pull upstream <remote_branch>


Credits goes to ru-mangos community, google and github help topics =)

#2 norrt

norrt

    Newbie

  • Plebs
  • Pip
  • 4 posts

Posted 26 August 2011 - 02:26 PM

plz help me - delete & remove commit

#3 USMAN

USMAN

    Newbie

  • Plebs
  • Pip
  • 3 posts

Posted 04 February 2012 - 08:33 AM

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

#4 Gregarious

Gregarious

    Advanced Member

  • Members
  • PipPipPip
  • 189 posts

Posted 05 February 2012 - 06:04 AM

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

[Guide] Fixing "Patch Does Not Apply" Errors

#5 killradio_1337

killradio_1337

    Advanced Member

  • Members
  • PipPipPip
  • 123 posts

Posted 13 February 2012 - 01:42 PM

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

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".

#6 MrSmite

MrSmite

    Advanced Member

  • Members
  • PipPipPip
  • 1,907 posts

Posted 07 April 2012 - 03:30 AM

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.


Edited by MrSmite, 19 August 2013 - 06:49 AM.

The noise in the dark is almost always scarier than what makes the noise in the dark.

 

- R. Ebert


#7 delro

delro

    Advanced Member

  • Members
  • PipPipPip
  • 179 posts

Posted 07 April 2012 - 03:51 AM

Epic guide!
Thank you very much :)
¿Necesitas ayuda y no entiendes el inglés? Postea tu duda en el sub-foro de español.
“Man cannot discover new oceans unless he has the courage to lose sight of the shore.”

#8 killradio_1337

killradio_1337

    Advanced Member

  • Members
  • PipPipPip
  • 123 posts

Posted 08 June 2012 - 03:58 AM

plz help me - delete & remove commit


git revert <hash>


example:

git revert ca9918e



#9 killradio_1337

killradio_1337

    Advanced Member

  • Members
  • PipPipPip
  • 123 posts

Posted 06 July 2012 - 03:12 AM

Learn git in 15 minutes ;)

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

A bit more online guides and how-tos:
http://rogerdudler.g....com/git-guide/
http://githowto.com/making_changes

#10 killradio_1337

killradio_1337

    Advanced Member

  • Members
  • PipPipPip
  • 123 posts

Posted 18 February 2013 - 01:49 PM

Rly interesting thing from Peter Cottle for those who wants to know more about GIT branchin:
8e7132076f76bc1c65eb1f4.png
http://pcottle.githu...rnGitBranching/

Supported commands:
  • commit
  • branch
  • checkout
  • cherry-pick
  • reset
  • revert
  • rebase
  • merge


#11 killradio_1337

killradio_1337

    Advanced Member

  • Members
  • PipPipPip
  • 123 posts

Posted 14 April 2014 - 05:20 AM

For those who want to have quick start with GIT:

 

GitHub Cheat Sheet

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

 

Link: https://github.com/t...hub-cheat-sheet