Jump to content

Making your own branch and using "old revisions"

Guest Garbaek

Recommended Posts

After searching the forums, I gave up and went to #git and asked the experts and I found out how to pull old revisions of mangos..

First you'll need to do

git clone git://github.com/mangos/mangos.git

cd mangos

git checkout -b yourbranchname 519bc25a215e095b573dafc62eb496e908cdae59

(Because we want http://github.com/mangos/mangos/commit/1d52f36ced501c8e284db7860470c73de85df9bf)

Then you can do

git show

should show something like this

splashgame@siara:~/mangos$ git show
commit [b]519bc25a215e095b573dafc62eb496e908cdae59[/b]
Author: ApoC <[email protected]>
Date:   Wed Jan 7 04:21:09 2009 +0100

   [7042] Forget to add revision number.

   Signed-off-by: ApoC <[email protected]>

diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index 05ad9af..1c80b3c 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "7041"
+ #define REVISION_NR "7042"
#endif // __REVISION_NR_H__

Now you can start to apply patches, compile and make your custom branch.



Link to comment
Share on other sites

What you probably didn't find out from your discussion is that as soon as you've cloned you already have your own completely custom branch :). By default that custom local branch is called "master", not to be confused with "origin/master" (which is by default the remote branch which your local master branch points to, but you can change that if you want with git reset). With git checkout -b X Y (shortcut to git branch X Y + git checkout X) you make additional local branches, but you don't really need that unless you want to be able switch between that and master quickly. For example if you create two databases, one for 303 and one for 242, you make two branches named A and B, one pointing to origin/master and one to origin/mangos-0.12, you add and commit the configuration files (with the matching database specified), you can switch between the two setups with a simple "git checkout A" or "git checkout B". That stuff is only made complicated by the database stuff, and it's the same for switching to older version. When database changes are not involved multiple branches become more useful. For example you could switch between a branch which contains only "vanilla" mangos and one which has your local changes, or you could have one branch which contains patches X,Y and one which contains Z,T. So if at any time you say "oops that patch totally messed something up", you just git checkout <the-previous-local-branch-that-worked>. You could also achieve similar things with revert. You apply a patch, commit it, and then you can pass that SHA of that commit to git revert to record another commit which reverts it. Maybe you have a branch which contains patches X,Y,Z but none with just Y,Z. Instead of removing all patches and applying Y,Z again you can just run revert on the commit where you added X.

Link to comment
Share on other sites

Thanks for the input!

and yeah I knew that what you clone becomes your own branch, I just had problems fiding a good guide on checking out older revisions, like right now, the 7050 rev, is broken, you cant do "make install" in linux without errors, so I needed to grab a older "working" tree, and there was no real help for this.. Hence the reason I made this guide.

:) I hope others will benefit from this.

Link to comment
Share on other sites

If you don't want to switch the remote tracking branch (like from origin/master to origin/mangos-0.12) but just ditch what you have now and go back a couple of revs till you find something that works, resetting your current branch is better that creating a new one I guess.

If you want to reset to the commit before the current: git reset --hard HEAD^

If you want to reset to 5 commits before the current: git reset --hard HEAD~5

Note that not all commits have rev numbers and it's generally recommended not to use commits which don't.

Link to comment
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use