This sounds crazy but every time I want to push a new project to my GitHub I have to relearn how to Push, Pull and Git shit. So there I was…casually updating one of my GitHub repositories…and here I am.. been stuck for 3 days LOL.
I uploaded to a repository then decided to update my local file and tried to push it but it was clashing with whatever was in the branch then 10,000 errors appeared.
So I’ve decided to write step-by-step how I do stuff on my blog to keep notes for myself and if anyone else is n00bing out like I am.
First of all, I got so annoyed and desperate I deleted the folder on my local computer. I’m not sure you should do this lol.
Then I restarted by cloning the repository to a new folder on my computer.
cd <insert path where you'd like to clone your repository>
Then I cloned the repository from my GitHub.
git clone <full GitHub link to repository>
Everything from my GitHub repository should now be in the new folder you made. It will be the same name as your GitHub repository unless you renamed it. Then I edited the file I wanted to edit.
***does some mad editing of exactly 1 line LOL***
This adds everything in the folder
git add .
or this adds just 1 file
git add <folder_name>
And then I had to push it to the branch by first adding it.
Then once that’s added (I actually have no idea where it’s added to I’m assuming cyberspace). You commit it and add a comment
git commit -m "Here is a comment that tells you what I updated"
Then you push it to a branch
git push origin master
Sometimes you may get an error message like
fatal: The current branch master has no upstream branch.
If the repository is created by git init then there is no remote origin. You will need to set it up by yourself by adding your repository.
git remote add origin <repo_url>
Repo_url is your repository URL on Github. Then you try to git push it again and it should work.
Phew, now that’s over… I hope this blog post refreshes my memory when I need it for the next project.
Sayonara!