Hi, I am very new to Git and source control in general, just started using it last week and its great so far, was a little frustration but after 7 repo’s and some more trial and error im up and running. I have a game project that i’m working on and I have 4 branches: master, Development, Experimental, and Volatile. I am working on the Experimental branch making changes and my programmer is working on the Development branch, my question is this: how do i pull his change from the development branch to the experimental branch without overwriting my changes in my branch? I’m using Source Tree UI but it has console in it, i havent delved into console very much at all but im sure its simple.
> how do i pull his change from the development branch to the experimental branch without overwriting my changes in my branch?
As long as you aren’t working on the exact same lines of code, you shouldn’t have any problem using the standard Git Merge functionality.
The technical documentation on branching and merging in Git is here:
I’m not familiar enough with Sourcetree to be able to tell you how to do it there, but it looks like they have some documentation on merging branches here:
And if you want to use the command line, in your particular case is sounds like it might be as simple as:
git checkout experimental git merge development
If you *are* working on the same lines of code, trying to merge the branches will likely give you a “merge conflict”, which we have some documentation about here:
Hope that helps you get started!
Great thanks! one more question, so lets say we make some commits to development, how do i update my other branches to make sure they have the latest updates from development? in source tree i selected Experimental branch and pulled from Development but am unsure if that is what im supposed to do, a console command would also suffice if you dont know how to do it in source tree. Thank you.
The general command-line form of how to merge from a branch named source into a branch named destination is:
git checkout destination # Changes your "working tree" branch to `destination` git merge source # Merges the differences between `source` and `destination` into the current branch
Beyond that, there are many possible scenarios that can occur in “update my other branches to make sure I have the latest updates”. It depends on how far diverged the source and destination branches are, how many and what type of merge conflicts, if you don’t want all changes but only some changes, etc. Unfortunately, there isn’t a one-size-fits-all solution to your general question … but the above is the most common thing people want when they ask your question.
I hope that helps!