How to Git in Unity- part 4
Previous article: How to Git in Unity- part 3
Since we successfully connected our local files to github, now we can use branch.
Branches are commonly using for different part in a project. For example, if your team are in develop with a racing game, there might a branch for modeling, car function scripting, or game system building. Branch can help each part or group to develop alone but also can be merged when in need.
To create and switch between branches by the following steps:
- Name your new branch in console:
git branch <branch name>
- Switch to new branch by using switch or checkout:
git switch/checkout <branch name>
- Your current branch will show on the right in blue.
4. We can create multiple branches and check all the branches:
5. While we switch to new branch and make some changes.
6. Add the changes and commit to new branch.
7. Then switch back to main and you’ll notice the script is gone.
Now we have multiple branches with different process, we can use merge to stick them together. When a work is reaching some big section, such as prepare for publish or release the alpha version. Use merge to collect all the works is fast and easy.
1.Switch to the branch that you want to create something.
2. Add all the changes and commit.
3. Switch back to the branch which we want to merge others in by using:
git merge <branch name>
4. We can push our new branch.
5. Now you got 2 branches as I do.