GitHub is an internet hosting website that has been around since 2008.
It’s used to host open-source projects(usually coding projects) and wikis.
This article will teach you how to use GitHub effectively, by teaching you
how to upload files into a GitHub repository and how to use the branch
function in GitHub.
Note: This article assumes that you’ve created a GitHub account, a first time GitHub user and is a Windows user.
Creating a GitHub Repository:
Once you’re on the main GitHub page, you need to click on the plus
button on the top right(highlighted red on the image below).
Once you’ve clicked on it, several buttons will be shown. You need to click
on New Repository. Once you’ve done all of that then you need to type
in your Repository name. You can choose whether it’s a public or private
repository. This is the most important part always tick the checkbox for Add README file this will setup a default branch which will be important
for later. Now click on the create repository button to create the
repository.
How to upload project files to GitHub:
Now that you’ve done creating a repository you may need to put your
project file onto GitHub. There are 3 ways to put a project to GitHub:
1. Traditional Git Bash method(Most reliable method)
2. Zip file method
3. Copy and paste method
Traditional Git Bash method
Firstly open Git Bash if you don’t have Git Bash then download it here.
Then type in Git clone (paste your repository link).
Once you’ve cloned your project you’ve to copy and paste your project
folder into the cloned folder. The clone folder can be found on
C:\Users\User in file explorer. Now copy and paste it into the cloned
folder. Open git bash again and type in Ls to see the list of folders in
C:\Users\User.
Type in cd (Cloned files). This basically allows you to access the folder as
seen in the yellow-colored text ~/JMeme below
Now type in git add (project folder). This basically tells GitHub that
you’re ready to add the files to GitHub and it’ll move it to a staging are waiting for it to be committed.
Next thing type in git commit -m “Your comment”. This basically move
the files from the staging area to the commit. After all your files has been
processed type in git push. This basically pushes your file to GitHub.
Sometimes after you’ve pressed enter after typing git push you might see
a pop up stating that you’ve to sign in.
You can close it by either signing in, but sometimes even if you put your
correct password it doesn’t work. To save your time and stop the
nuisance open GitHub desktop, if you don’t have it download it here.
Import your repository to the file and then push it through here.
Sometimes before you need to sign in you may encounter this problem:
To fix that make sure your file is one layer(Make sure it’s not folder after
folder after folder inside your file) and then paste git push origin
HEAD:master to push to other branch or git push origin HEAD to your
main branch
Zip files method
This method only works for files that’s less than 25 MB after zipped as
GitHub has a file limit. To zip your file just right click on “Compressed(zipped) folder”. Now you’ve got the file just go to your
repository and click on the Add file button and then click on upload files
and then locate your zipped files and click on it
Copy and paste method
The last method is very simple but has plenty of limitations but it’s the
easiest method to upload simple projects. To do that just click on Add
files then click on create new file. Type your name of the file make sure to
include the files formats in it and just paste all of your code in there. This
works well if you’ve a file full of Python or Javascript code
“JMeme.cs”
For clearer instructions checkout Notchmods GitHub tutorial.
Now after we’ve uploaded the file, chances are that we might keep
working on them and after we’ve finished the update, we need to upload
another version of it to GitHub. Well luckily for you, GitHub has the
branch function, so that means that you don’t have to delete your files.
To create a branch just type in git branch -c “branch name”. Once you’ve
opened a branch type in git branch to check out the list of branches
that’s in the git branch.
To move to access the other branch type in checkout (branch name). This
basically allows you to access other branches. Now you can repeat the
same thing above and upload your folder through git bash.