- Once you have logged into your Github go to repositories and select New
- From there fill in the relevant details as shown in the image below
- You do not need to create a README.md file at this point if you do not want to
- Once you have created your repository you will be taken to the following page where the steps below will assist you
- This tutorial will utilise the SSH protocol so ensure you have created a key using the following tutorial SSH key tutorial
- Open your terminal (Gitbash etc) as ADMIN
- Ensure you create a new directory/folder using the same name as your repo, in the case of the above example this would be "
mkdir test
" - Once created ensure you change to the relevant directory "
cd test
" - You may then use "
git init
" in order to initialise an empty repo in said folder - using "
nano README.md
" you can create an md file - then use "
git add .
" - You must then commit using "
git commit -m "whatever you wish to call it"
" - You can then use "
git branch -M main
" - You may then paste the remote add origin that is shown on the Github repo page, mine looks like this "
git remote add origin git@github.com:Pravin-Selvaranjan/test.git
" - If you receive an error to do with your public key follow the steps at key agent
- Finally you may use "
git push -u origin main
"
You should then be able to refresh your repo on Github and see that the md file you created locally is viewable.
git init (initialise)
- This command is used to start a new depository (be sure to only complete this task once you have created the correct folder on your localhost using mkdir)git add
- This command adds a file to the relevant area (using an * or . adds all of the files available)git commit
- This command records the file in the version historygit push -u origin main
- This command sends the committed changes of master branch to your depositorygit pull
- This command fetches and merges changes on the server to your local directory
Sometimes you may initialise a git folder in the wrong location ie allowing your entire machine contents to be uploaded. If you see (master) after your default command line - this is most likely the case.
- Delete the git folder by using rm - rf .git
- Be sure to have created a folder using the exact name of the folder you made on Github!!