top of page

Git 101 - How to connect your project to GitHub

  • thetperson314
  • Jul 30, 2021
  • 2 min read

Updated: Aug 25, 2021

Connect Your Project


If using the new GitHub go to the bottom


To make this easier to understand lets make our user name 'NerdHead' and our repository (git project) name to 'CoolGame'


Now our project Url will be: https://github.com/NerdHead/CoolGame


After downloading and installing Git on your computer open the file location right click and open the 'Git Bash Here'



git init
git add .
git commit -m “First Commit” 
git remote add origin https://github.com/NerdHead/CoolGame
git push --set-upstream origin master

If comment 4 not working make sure that your are on the right branch (master) by using

git branch

If you are on the master branch use

git fetch
git checkout main

Than you can continue from the 4th stage again


* take note that the last commend makes the main branch to be main, some other websites might make it with another name (like 'master' let's declare as wrong branch)


Now when you go to your GitHub project page and hit refresh you will see all of your files.


Fixing git pus

If you can't see your files that means that your filed are in another branch (probably because you used another name instead of main in stage 5).


To fix this just combine the branches use:


git fetch
git checkout main
git merge master

This might not work, if so use:


git checkout master
git branch main master -f
git checkout main
git push origin main -f

If using the new GitHub


There is a problem with the new update to GitHub that might cause some problems for you, the GitHub main branch is called main but the Git main branch is master by default.


to fix this all you need to do it to switch to the main branch before adding anything to the git.


your code will look like this:


git init
git checkout -b main                                                     git pull https://github.com/NerdHead/CoolGame main                        git fetch
git add .
git commit -m “First Commit” 
git remote add origin https://github.com/NerdHead/CoolGame
git push --set-upstream origin main
 
 

Recent Posts

See All

FAVORITES

Try playing Core Keeper and learn from it's sound design!

From the sound effect to the music - this is a masterpiece!

WHAT'S NEW?

New game on Steam and a new mobile video asset are soon to be published!!

I AM THINKING ABOUT

AI is on the rise. Being able to use it in the right cases and explaining the task correctly is no easy task but once you finish a full task without writing a line of code - your world will change!

CONTACT ME

Use any social media to contact me. For any question about programing and project I prefer using my Discord server, See you there!

© 2021 by Amit Klein. Nerd Head.

bottom of page