-
Notifications
You must be signed in to change notification settings - Fork 305
Git Good at Git Operations
We're finally done with setup! However you probably don't know how to use TortiseGit. Don't worry, this guide will tell you how to do many operations with Git using TortoiseGit.
Before you start working on something, making sure you're up to date is always a good idea.
- Updating your source code with the master should be done before trying anything.
- Right-click the folder your source code is in and select TortoiseGit then Pull.
- Click the radial button next to Remote and make sure upstream (or whatever you called it) is selected next to it.
- The remote branch should be set to master.
- Then click Ok. This will pull the latest changes from the master repo.
Branches allow you to organize your changes. By default, when you cloned your copy of the code, the branch you start on is called master. You should never work directly on the master branch. You should only update the master branch, or make a new branch and work on that one. The reason for that is so you can fall back to the master branch if you make a mistake you're unable to fix on a separate branch, without needing to reinstall the source code.
Branching your source code is also very important for organising your commits. You should have a different branch for each unrelated code change (e.g. if you wanted to make some new sprites for one item and change the properties of another these should be in seperate branches), as Pull requests work off branches rather than commits this will allow you to make a seperate Pull Request per change. Doing this streamlines the whole process and will save everyone a bunch of headaches.
- Right-click in your working folder. Then choose TortoiseGit, and Create Branch… * Type in your new branch name
- (Optional) Tick Switch to new branch , if you want to work on it immediately.
- Press Okay and your new branch is created.
To switch between Branches:
- Right-click in your working folder. Then choose TortoiseGit, and Switch/Checkout…
- Choose your Branch then press Okay.
Note that TortoiseGit will complain if you have uncommitted changes. If have those, commit, stash, or revert them before switching.
A commit is confirmed change of the files in your source code repository, it's how you make changes permanently to the files in your repo, so try not to commit without making sure it works (though subsequent commits can fix it).
- As said before, you should use different branches to separate your commits/changes. Don't commit to master. It should be clean, so you can fall back on it if needed.
- To make changes to the code that you can commit, you should edit the files using BYOND's inbuilt editing tools. Make sure to follow coding standards when making your changes!
- When you're finished, right click the folder you're working with and choose Git Commit → “Branch Name“ (Example: Git Commit → “My_First_Branch”)
- You can then select only the files you want to be committed by ticking or unticking them. You should also write a detailed commit summary, detailing what happened in that commit.
- Click Ok and the commit will be committed to your local repo!
After you've made a change to the code, you probably want your change to make it to Polaris's server. Before that can happen, you need to push your commits (changes) to your origin remote, which should be the fork of the code that's sitting on Github.
Fortunately, if you cloned your source code, origin should already be set up.
- Right-click in your working folder. Then choose TortoiseGit, and Push…
- Set Local and Remote to the name of the branch you committed before. (e.g. My_First_Branch). If Remote is empty, copypaste your local branch name to it, and it'll get made as you push.
- Under Destination, set Remote: to origin.
- Click Ok. This'll upload your changes to your remote repo (the one on GitHub).
- Head to your GitHub repo e.g https://github.com/NAME/Polaris.git
Now that your changes are on your origin remote, you'll need to get them onto your upstream remote. To do this, you'll need to request that your changes are incorporated into the source code of the upstream repository.
- Navigate to your fork on Github.
- Click Pull Request at the top right.
- Make sure you don't see a red 'cannot merge' anywhere on the page.
- Fill out a summary and then create the pull request.
You're done! In many cases there will be issues pointed out by other contributors, unfortunate merge conflicts, and other things that will require you to revisit your pull request.
Sometimes, you manage to break your copy, and you'd like to start over, or perhaps you want to switch branches and don't want to commit your changes, and don't care of losing the work you did. You can easily revert your latest, uncommited changes, so it will be as if you never made a change. Be careful as you cannot recover these changes, ever.
- Right click your repo folder > TortiseGit > Revert
- Select all the files you want to revert.
- Click Ok