-
Notifications
You must be signed in to change notification settings - Fork 28
Setting up Git for the command line
Note: This guide is likely only relevant for Windows. CLI commands will be in code blocks.
Git is a version control system and how we interact with this repository.
- Repository (repo) - the thing where the code is kept. The main repo is Baystation12/Baystation12, your fork will be yourname/Baystation12.
- Commit - a thing containing information about what you changed and where, and a message describing those changes
- Push - moving your commits to your repo
- Pull - moving other people's commits to your local copy of the repo
- Branch - different versions of the repo, allowing you to make different changes touching different files without having to commit them all at once
- Pull request - a request that the main repo pull yours, merging your code changes into the master version
Commit messages should follow a few guidelines:
- The first line is the commit subject line and:
- should be less than 50 characters
- should be imperative, as if you're telling the computer what to do (Add new uniforms, Remove Security, Make changes to jobs file)
- An easy way to tell if you're doing it right is to enter it into the following sentence: If merged, this commit will your subject line
- Every following line makes up the body of the commit message, and should be less than 72 characters long each. This is where you can (optionally) describe why you're making your changes, but you can always do this later on GitHub.
-
Go to https://git-scm.com/download and download the relevant version.
-
Create a GitHub account, if you've not done so already. It's helpful if your name there is similar to the one you use on Discord/IRC/the forum.
-
Install Git, leaving everything at their defaults.
-
Open the command line (WIN-X -> Command Prompt)
-
Enter the following commands to set up your Git identity:
- git config --global user.name "your name" (can be your real name or username or whatever you want, but it will be viewable
- git config --global user.email "email@example.com" (same deal as above, this should be a real email address, and probably the same as the one you registered on github with)
-
Go to https://github.com/Baystation12/Baystation12 and click the Fork button in the top-right. GitHub will do some stuff.
-
It's time to download the repo, so find a folder you're happy the files being in and use the
cd
command (ex:cd C:\folder\folder
, and remember you can copy-paste into command prompt) to move there, or open the command prompt there using the File tab. -
Enter the command
git clone https://github.com/Baystation12/Baystation12.git
and wait for it to complete. -
Once it's complete, you'll need to
cd Baystation12
- then entergit status
to ensure that cloning was successful. You should see On branch dev - Your branch is up to date with origin/dev - Nothing to commit, working tree clean -
Now enter
git remote add fork https://github.com/YOUR GITHUB USER NAME/Baystation12.git
. This will be what you commit and push to so you can open pull requests to the main repository. -
Now you need to create and switch to a new branch. Type
git branch nameofbranch
to create a branch, thengit checkout nameofbranch
to switch to it. You should get confirmation messages for the checkout command, such as 'Switched to branch 'nameofbranch' -
It's time to make some changes. Open a file in your local copy and change anything. This is just for testing and demonstration purposes, so anything is fine. Then type
git status
and you'll see a message about changes not staged for commit.- If you're making real changes, always remember to compile and test your changes before opening your pull request.
-
Type
git commit -a
and a text editor will open. Crazy, right? Any lines preceded by a hashtag/pound sign/# is a comment - Type your commit message above these lines. -
Once you've finished writing your commit, save the text file and close the text editor. The command line will do some stuff and then give you your commit subject and a short summary of changes.
-
Now it's time to push your changes to your fork. Enter the following command:
git push fork
. This shoves your branch's changes up to your repo. -
Head back to https://github.com/Baystation12/Baystation12 and click the New Pull Request button (if you don't see the green button on the left hand side, which I couldn't get to show up for this guide, but you'll know it if you see it)
-
Once you're in the pull request menu, first click 'Compare accross forks, then select your repository from the list, then select your branch from the menu named 'compare: dev'.
-
You'll now see the pull request editor gimmick, which is pretty self explanatory. The title is the title of the PR (automatically filled with the 1st commit's subject) and the body is the description, what it does, etc (automatically filled with the commit descriptions)
-
Click the green 'create pull request' and you've successfully created a pull request! Wow!
-
After you've opened your pull request, you might want to switch back to the base branch of the repo, dev. You can do that by typing the command
git checkout dev
. After a few days, your repo will be out of date, so you'll need to typegit pull
to update it.
Documentation regarding setting up and using Git.
Making heads or tails of specific GitHub pages, for the uninitiated.
Documentation regarding tools external to DM and Git.
Standards and guidelines regarding commenting, contributor conduct and coding standards.