Jump to content

[guide] getting mangos + forked branch + updating


Recommended Posts

Is it possible to clone a branch from a remote repository into an already created repository without pulling/merging?

For example if I do this:

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

git remote add fork [email protected]: Dythzer/mangos.git

git checkout -b testbranch

git pull fork testbranch

It will create a commit with message:

Merge branch 'testbranch'' of [email][email protected][/email]:Dythzer/mangos into testbranch

Instead I want it to copy all commits from a branch on my fork without merging them into one commit on the current branch, is it possible without having two repos, one for mangos and one for mangos fork? So when I want to update mangos I just do git pull in master branch and when I have changed something in my fork and want to push it I just do git push fork testbranch. I had like that before I deleted the branch, now I want it back but if I pull it will just merge it, I want to have it back in the same state as before. I hope you understand what I mean.

http://getmangos.eu/community/viewtopic.php?id=4160 .. man git-remote ;)

Link to comment
Share on other sites

  • 38 years later...

i try to write a generic, simple, fast forward tutorial about how getting mangos and then getting my alterac branch, so that you can start with this spare knowledge to get other branches and also get used to git

at first: i started with git somewhere in august, and don't know very much about it, so some things may be not so good - also this is only tested at linux (gentoo)

also i don't explain the commands very much (mostly because the endless features^^)

getting mangos:

git clone giturl [targetdir]

targetdir is optional, if not specified it will get downloaded to the directory "mangos"

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

updating mangos:

git pull [giturl/alias [remote-branch]]

the alias origin will be added if you cloned mangos with the above command, but in the next step i show you how to set up own aliasses (not very important, but i like them)

remote-branch is the branch, in the internet, which you want to get, cause mangos currently only develops in master, you don't need any other branches

$ cd source
$ git pull origin master

how to get another fork

first thing, which make future stuff easier is:

git remote add balrok [url]git://github.com/balrok/mangos.git[/url]

------- side note: at this point you should know how to handle local branches, it will make things much easier later ----- now you can get a branch with

git pull balrok alterac

to get a list of all branches from me, look at the github-webpage (notice, that some branches depend on another (for example generic_bg_queueid depends on arena and bonushonor on queueid)

to update mangos and/or alterac you just run

git pull origin master
git pull balrok alterac

when you don't like the alterac branch anymore, just run

git reset --hard origin/master

(i haven't used this command yet very often, so i hope, it will work like i expect it (: )

this will also delete any other non-"origin/master" branches

conflicts:

if you want to play around with them, you can get a conflict with

git pull balrok alterac
git pull balrok arena

it's quite easy to resolve everything, just take the stuff, which is new in arena, and delete those ">>>>" "====" and "<<<<" things..

but i can't give you good hints about this part, cause i'm not very experienced with this and will maybe lead you to something wrong

as i said before i'm quite new, but you can ask questions, or maybe give me some advices (i haven't searched yet, but it will be nice to have the alterac-branch in an own local branch with it's complete history (if this is possible))

Link to comment
Share on other sites

there is a branch merged_arena which is a av-arena branch but i don't know, if i maintain it any longer..

for merging conflicts (i left it out of my guide, cause i am not very familar with it)

first you see conflicts after pulling arena over alterac:

CONFLICT (content): Merge conflict in src/game/BattleGround.cpp
CONFLICT (content): Merge conflict in src/game/Language.h
CONFLICT (content): Merge conflict in src/game/Unit.cpp

then you also can do "git status" (maybe with "git status | grep unmerged"

and i use git mergetool for resolving those conflicts

i get vimdiff, close yourfile.LOCAL window

and with "d+o" i obtain stuff from remote (will be arenastuff) deleting "===" ">>>" and "<<<" things

but merging those two patches is realy trivial, mostly you have to remove "=="-stuff cause both patches don't have much different code..

@theluda:

i thought i leave the branches out of this guide, cause if someone don't know how branches work, i need to explain him everything, and if someone knows branching, he surely can do it by himself..

this guide is just something for those very new users, which should get a small idea how to do some cool things with less knowledge ^^

Link to comment
Share on other sites

Is it possible to clone a branch from a remote repository into an already created repository without pulling/merging?

For example if I do this:

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

git remote add fork [email protected]: Dythzer/mangos.git

git checkout -b testbranch

git pull fork testbranch

It will create a commit with message:

Merge branch 'testbranch'' of [email][email protected][/email]:Dythzer/mangos into testbranch

Instead I want it to copy all commits from a branch on my fork without merging them into one commit on the current branch, is it possible without having two repos, one for mangos and one for mangos fork? So when I want to update mangos I just do git pull in master branch and when I have changed something in my fork and want to push it I just do git push fork testbranch. I had like that before I deleted the branch, now I want it back but if I pull it will just merge it, I want to have it back in the same state as before. I hope you understand what I mean.

Link to comment
Share on other sites

  • 2 weeks later...

Following this guid i did:

balrok.sh

git clone  git://github.com/mangos/mangos.git source
cd source
git pull origin master
git remote add balrok git://github.com/balrok/mangos.git
git pull balrok arena

Result was:

jman@jman-ubuntu:/media/mangos$ ./balrok.sh
Initialized empty Git repository in /media/mangos/source/.git/
remote: Counting objects: 5616, done.
remote: Compressing objects: 100% (4511/4511), done.
remote: Total 5616 (delta 2449), reused 3879 (delta 1058)
Receiving objects: 100% (5616/5616), 14.88 MiB | 285 KiB/s, done.
Resolving deltas: 100% (2449/2449), done.
Checking out files: 100% (3368/3368), done.
From git://github.com/mangos/mangos
* branch            master     -> FETCH_HEAD
Already up-to-date.
remote: Counting objects: 197, done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 103 (delta 87), reused 36 (delta 27)
Receiving objects: 100% (103/103), 218.43 KiB | 97 KiB/s, done.
Resolving deltas: 100% (87/87), completed with 51 local objects.
From git://github.com/balrok/mangos
* branch            arena      -> FETCH_HEAD
Auto-merged src/game/BattleGround.cpp
Auto-merged src/game/BattleGroundBE.cpp
Auto-merged src/game/BattleGroundEY.cpp
Auto-merged src/game/BattleGroundMgr.cpp
Auto-merged src/game/BattleGroundRL.cpp
Auto-merged src/game/BattleGroundWS.cpp
Auto-merged src/game/CharacterHandler.cpp
Auto-merged src/game/Chat.cpp
Auto-merged src/game/Chat.h
Auto-merged src/game/Language.h
Auto-merged src/game/Level3.cpp
CONFLICT (content): Merge conflict in src/game/Level3.cpp
Auto-merged src/game/MiscHandler.cpp
Auto-merged src/game/Player.cpp
Auto-merged src/game/Player.h
Auto-merged src/game/SpellEffects.cpp
Auto-merged src/game/Unit.cpp
Auto-merged src/game/Unit.h
Auto-merged src/game/World.cpp
Auto-merged src/game/debugcmds.cpp
Auto-merged src/mangosd/mangosd.conf.dist.in
Automatic merge failed; fix conflicts and then commit the result.
jman@jman-ubuntu:/media/mangos$ 

Merge problems = branch not updated am i right?

If i am how do i solve conflick manually? I need to know where are the pach files containing the new code stored bu git so that i can open them and copy paste all new code by hand?

Link to comment
Share on other sites

Following this guid i did:

balrok.sh

git clone  git://github.com/mangos/mangos.git source
cd source
git pull origin master
git remote add balrok git://github.com/balrok/mangos.git
git pull balrok arena

Result was:

jman@jman-ubuntu:/media/mangos$ ./balrok.sh
Initialized empty Git repository in /media/mangos/source/.git/
remote: Counting objects: 5616, done.
remote: Compressing objects: 100% (4511/4511), done.
remote: Total 5616 (delta 2449), reused 3879 (delta 1058)
Receiving objects: 100% (5616/5616), 14.88 MiB | 285 KiB/s, done.
Resolving deltas: 100% (2449/2449), done.
Checking out files: 100% (3368/3368), done.
From git://github.com/mangos/mangos
* branch            master     -> FETCH_HEAD
Already up-to-date.
remote: Counting objects: 197, done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 103 (delta 87), reused 36 (delta 27)
Receiving objects: 100% (103/103), 218.43 KiB | 97 KiB/s, done.
Resolving deltas: 100% (87/87), completed with 51 local objects.
From git://github.com/balrok/mangos
* branch            arena      -> FETCH_HEAD
Auto-merged src/game/BattleGround.cpp
Auto-merged src/game/BattleGroundBE.cpp
Auto-merged src/game/BattleGroundEY.cpp
Auto-merged src/game/BattleGroundMgr.cpp
Auto-merged src/game/BattleGroundRL.cpp
Auto-merged src/game/BattleGroundWS.cpp
Auto-merged src/game/CharacterHandler.cpp
Auto-merged src/game/Chat.cpp
Auto-merged src/game/Chat.h
Auto-merged src/game/Language.h
Auto-merged src/game/Level3.cpp
CONFLICT (content): Merge conflict in src/game/Level3.cpp
Auto-merged src/game/MiscHandler.cpp
Auto-merged src/game/Player.cpp
Auto-merged src/game/Player.h
Auto-merged src/game/SpellEffects.cpp
Auto-merged src/game/Unit.cpp
Auto-merged src/game/Unit.h
Auto-merged src/game/World.cpp
Auto-merged src/game/debugcmds.cpp
Auto-merged src/mangosd/mangosd.conf.dist.in
Automatic merge failed; fix conflicts and then commit the result.
jman@jman-ubuntu:/media/mangos$ 

Merge problems = branch not updated am i right?

If i am how do i solve conflick manually? I need to know where are the pach files containing the new code stored bu git so that i can open them and copy paste all new code by hand?

I encountered the same "problem" yesterday as well, it's a very simple conflict, just edit the file (go to the end) and resolve it ...

Link to comment
Share on other sites

I don't know if it is really related, but this is how I do it (with the impconfig settings):

git clone <mangos git url> (clone mangos)

git am src/binding/scriptdev2/patch/<the latest patch> (apply scriptdev2 patch)

git remote add impconfig <impconfig's git url> (add impconfig fork)

git fetch impconfig/impconfig (download, but not apply impconfig)

git merge impconfig/impconfig (merge latest impconfig with mangos)

configure, compile, install, ??, profit? (lol)

to update:

git fetch origin

git fetch impconfig (download latest of each, but not apply yet)

git rebase impconfig/impconfig (this will start at impconfig's latest commit, then apply the latest mangos commits, then apply the scriptdev patch)

configure, compile, install, ??, profit again? (lol again)

I like git, been using it for a long time (Wine, linux kernel, etc)

This is useful if you follow the "interesting git branches" thread or have patches that you use (like scriptdev, etc) It _should_ show you when conflicts arise too, like when the scriptdev guys use a new patch etc.

If i am how do i solve conflick manually? I need to know where are the pach files containing the new code stored bu git so that i can open them and copy paste all new code by hand?

I believe git-diff will show you the problem areas in this case, don't quote me on that, i don't remember exactly right off

Link to comment
Share on other sites

git fetch impconfig/impconfig (download, but not apply impconfig)

So it works this way as well? I thought you have to specify optional refspec like "<remote> <refspec>" without the slash ...

to update:

git fetch origin

git fetch impconfig (download latest of each, but not apply yet)

git rebase impconfig/impconfig (this will start at impconfig's latest commit, then apply the latest mangos commits, then apply the scriptdev patch)

configure, compile, install, ??, profit again? (lol again)

(even if your previous impconfig/impconfig had downloaded only impconfig branch, this fetch will download everything:))

Making it this way isn't the best. Yes, you fetch also origin, but you do only one rebase, so your branch isn't updated from origin, but from impconfig (thus depending on it's author to merge mangos/master regullary, which don't have to be necessarily true as merge compares two tree objects).

So (imho) the better way when updating things would be to hard reset the current branch and then re-applying the rest with rebase.

Like

(I suppose you don't have your custom changes on current branch)
git reset --hard origin/master          (hard-reset your branch to the remote master)
git pull --rebase impconfig impconfig          (fetch + rebase the remote one into your current)

Good luck.

Link to comment
Share on other sites

You are absolutely correct, i forgot to write a step.

Yes, git fetch rebase impconfig/impconfig is the same as git rebase impconfig impconfig - either works

git fetch origin

git fetch impconfig (download latest of each, but not apply yet)

git rebase impconfig/impconfig (this will start at impconfig's latest commit, then apply the latest mangos commits, then apply the scriptdev patch)

configure, compile, install, ??, profit again? (lol again)

Should have been:

git fetch origin
git fetch impconfig (download latest of each, but not apply yet)

[b]git rebase origin (to apply the latest mangos commits) [/b]
git rebase impconfig/impconfig (this will start at impconfig's latest commit, then apply the latest mangos commits [again], then apply the scriptdev patch)

configure, compile, install, ??, profit again? (lol again)

Just like you said, it's important to not forget a step :-p

Link to comment
Share on other sites

  • 3 weeks later...

Hey balrok,

i`ve using debian etch with git and git-core installed. I tried to follow your tutorial, but when i run

git remote add balrok git://github.com/balrok/mangos.git

i get a

git: 'remote' is not a git-command

. My git version is 1.4.4.4.

Any ideas?

regards warrior

Link to comment
Share on other sites

hello & thanks for tuto, worked fine till now

but i can't pull Alterac on last mangos master 6872 (fresh source) - any fix in this case ? thanx

Welcome to Git (version 1.6.0.2-preview20080923)

Run 'git help git' to display the help index.

Run 'git help <command>' to display help for specific commands.

$ git remote add balrok git://github.com/balrok/mangos.git

$ git pull balrok alterac

remote: Counting objects: 867, done.←[K

remote: Compressing objects: 100% (289/289), done.←[K

remote: Total 775 (delta 647), reused 580 (delta 486)←[K

Receiving objects: 100% (775/775), 178.58 KiB | 29 KiB/s, done.

Resolving deltas: 100% (647/647), completed with 51 local objects.

From git://github.com/balrok/mangos

* branch alterac -> FETCH_HEAD

error: Entry 'src/game/AggressorAI.cpp' not uptodate. Cannot merge.

fatal: merging of trees 41ce6ccd7291d4a222794b715e389d6fed8495f9 and 2e08f5699c4

4ef6030188bf99829b0fe9b28b4eb failed

Merge with strategy recursive failed.

Link to comment
Share on other sites

hello & thanks for tuto, worked fine till now

but i can't pull Alterac on last mangos master 6872 (fresh source) - any fix in this case ? thanx

Welcome to Git (version 1.6.0.2-preview20080923)

Run 'git help git' to display the help index.

Run 'git help <command>' to display help for specific commands.

$ git remote add balrok git://github.com/balrok/mangos.git

$ git pull balrok alterac

remote: Counting objects: 867, done.←[K

remote: Compressing objects: 100% (289/289), done.←[K

remote: Total 775 (delta 647), reused 580 (delta 486)←[K

Receiving objects: 100% (775/775), 178.58 KiB | 29 KiB/s, done.

Resolving deltas: 100% (647/647), completed with 51 local objects.

From git://github.com/balrok/mangos

* branch alterac -> FETCH_HEAD

error: Entry 'src/game/AggressorAI.cpp' not uptodate. Cannot merge.

fatal: merging of trees 41ce6ccd7291d4a222794b715e389d6fed8495f9 and 2e08f5699c4

4ef6030188bf99829b0fe9b28b4eb failed

Merge with strategy recursive failed.

You probably don't have "fresh source", see git status.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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