Foreword, I'm fairly new to using git and versioning systems in general. I think I understand most of the concepts, but i seem to have run into a wall here/ I'm using smartgit as my client, which may be relevant, and coding for a game server
So a couple of weeks ago, I started on a major project, branching off of our project's development branch. During that time, there's been a major update to the codebase, and a few things have changed that cause my branch to not compile. Apparently, it's not using the current development branch as a base, but the state of the development branch when I started this project, and the new changes don't seem to be merging into the local code
I've just started using smartgit, and there's a whole tide of features I don't quite understand.
Here's the tooltip branch for my project, DionaOverhaul:
The base branch that I originally branched off of, was aurorastation/development
. I'm thinking maybe that should be set as the tracked branch?
I need to merge all the changes to aurorastation/development
into my dionaoverhaul
branch somehow, and create a branch that has all the current development code, with my dionaoverhaul
commits ontop of it. and I'm not sure how to go about it.
After a bit of research, i think what i want to do is to rebase my branch to the tip of aurorastation/development
but one problem i see with that, is that at least one of the tiles i'm working on, has been changed in the meantime, and i don't want to entirely overwrite the changes to that file, with the version that's in my branch. I'm not sure if that's something the repository manager will handle when merging my pull request, or whether its something i need to take care of during the rebase
You have two branches: your_local
and development
.
Once you finished your_local
and want to bring all the changes to development
you have two options :
development
branch, pull all the changes in, and merge your_local
into it. development
, pull all the changes in, switch back you your_local
, merge development
into it and resolve all the conflicts. Then go to option 1. First option is a simple case when you have no big changes in development
.
The second one looks like your case: there are changes in development
and they are conflicting with yours.
Actually, there are more (you can rebase your_local
onto latest development
for example), but let's keep is simple for now.
You don't need to change tracked branch, this is a pointer to the remote copy of your local branch .
when you have conflicting changes in both development
and your_local
git will try to resolve it (that's what git is for). However it's not always possible and git will mark such files as conflicting, and you will have to manually resolve those conflicts.
Smartgit has some basic functionality for merging and resolving conflicts.
Anyway, if you're not very familiar with git/smartgit I recommend you to backup your repository so that you can experiment with merge without worrying too much.
"Tracked branch" means the branch that you push to. It should always be the same as the name of the local branch, prefixed by "refs/remotes/NAME_OF_REMOTE". NAME_OF_REMOTE can be anything, but if you only push to one server, the convention is to call it "origin". So don't change it. If you do, the next time you push, you will get a message that you can't push because it would overwrite the remote branch, and if you're sure you want to do that, use git push --force
. If you use git push --force
, you will end up overwriting someone else's hard work on the development branch. (Yes, it is recoverable, but it's a headache so just don't.)
I need to merge all the changes to aurorastation/development into my dionaoverhaul branch somehow, and create a branch that has all the current development code, with my dionaoverhaul commits ontop of it
You have 2 options. If you really want all your dionaoverhaul commits ontop of it
, then do this:
git add -A && git rebase --continue
On the other hand, if you'd prefer to only have to deal with at most 1 set of manual conflicts, then use merge
instead of rebase
. The disadvantage is that your branch's history will no longer be one straight line. There are many advantages to this approach, however, that are byond the scope here. To merge, instead of running git rebase origin/development
, run git merge origin/development
. Again, you may have to deal with manual conflicts, but once they are all resolved, use git add -A && git commit
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.