This guide uses TortoiseGit. While there are other programs out there, this one is very beginner friendly. This guide is for Windows only.
Some videos that are recommended watching for any Git user:
- https://www.youtube.com/watch?v=MYP56QJpDr4 - Git From the Bits Up
- https://www.youtube.com/watch?v=4XpnKHJAok8 - Tech Talk: Linus Torvalds on git
- https://www.youtube.com/watch?v=ZDR433b0HJY - Introduction to Git with Scott Chacon of GitHub
- Go here: https://gitforwindows.org/
- Download Git.
- It should look something like
Git-2.29.2.2-64-bit.exe
- Install it and leave everything on default (just keep clicking next).
- Wait till the installer has finished.
- Head over here: https://github.com/
- Click
Sign up
in the top right-hand corner. - Create an account with your username and email.
- Go here: https://tortoisegit.org/download/
- Download the right TortoiseGit for your system
- The file should look something like
TortoiseGit-2.11.0.0-64bit.msi
- When the install is done run the first start wizard
- Make sure your install of Git is being detected
- Fill out the same username and email address you used on GitHub
- You can leave everything else as default for now
Forking code allows you to edit it without affecting the main repository, in mose cases you would not have access to edit unless you do so.
- Head over to the Git repo you want to edit.
- For example:
https://github.com/CorruptComputer/ProtonDB-Tags
- For example:
- Click the
Fork
button in the top right corner. - The page you'll be directed to is now your fork. You'll be pushing updates here, and making pull requests to have them merged the main (master) repository.
- Copy the URL to your fork.
- Using the same example as above, it would look like this:
https://github.com/[YourUsername]/ProtonDB-Tags
- Using the same example as above, it would look like this:
- Find where you want the folder for the code to be.
- Right click and choose
Git Clone...
- The URL field should be filled with the URL of your Fork. If not, paste it in.
- Click Next and watch flying tortoises bring you your code.
- Right click on the folder that was created, and go to
TortoiseGit
and then click onSettings
. - Click on
Remote
underGit
. - There should be one thing on the list of remotes, with the name:
origin
. - You're now adding the main repository as a source you can pull updates from.
- In the
Remote
box type inupstream
. - In the
URL:
box put the GitHub URL of the Repo you forked from - Click
Add New/Save
. - Click
Ok
. - Almost done!
- Updating your repo with the
upstream/master
should be done before trying anything. - Right-click the folder your repo is in and select
TortoiseGit
thenPull
. - Click the radial button next to Remote and make sure
upstream
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.
Branching your repo is very important for organizing your commits, you should have a different branch for each unrelated code change (e.g. if you wanted to fix a typo in the UI, and you want to add another feature), as Pull requests work off branches rather than commits this will allow you to make a separate 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
, andCreate Branch...
- Type in your new branch name
- (Optional) Tick
Switch to new branch
- Press
Okay
and your new branch is created
To switch between Branches:
- Right-click in your working folder. Then choose
TortoiseGit
, andSwitch/Checkout...
- Choose your Branch then press
Okay
- A commit is confirmed change of the files in your repo, 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.
- When you're finished editing the code, right click the folder you're working with and choose
Git Commit -> "[Your Branch Name]"
(Example: Git Commit -> "My_First_Branch") - You can then select only the files you want to be committed by ticking or un-ticking 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!
- Right-click in your working folder. Then choose
TortoiseGit
, andPush...
- Set
Local
andRemote
to the name of the branch you committed before. (e.g. My_First_Branch) - Under Destination, set Remote: to
origin
. - Click
Ok
. This'll upload your changes to your remote repo (the one on GitHub).
- Head back to your GitHub repo.
- Click
New Pull Request
. - Fill out a summary and then create the pull request.
- You're done! In many cases there may be issues pointed out by other contributors, unfortunate merge conflicts, and other things that will require you to revisit your pull request before it is merged.
- Optionally, view step 12 for a guide on cleaner commit logs, cleaner commits help when reviewing your code!
- If your commit logs are filthy, full of one or two line commits that fix an error called
Whoops
oroops
, this looks bad and makes it more difficult to look back through the logs. This will help you! - Navigate to your local version of the branch
- Ensure it is up to date with the
remote
- Go to
Show log
- Select all the commits associated with this change or PR
- Right click and choose
Combine to one commit
- This will open up the standard commit interface for TortoiseGit, with the commit logs of the selected commits merged together
- Perform the normal routine for a commit
- Go to
push
your branch to theremote branch
- Ensure
Force Overwrite Existing Branch (may discard changes)
is selected to make sure the PR/Remote updates to contain just this squashed commit