'How to push to origin master in Git?
I am new to Git and I am teaching myself because tomorrow I have to teach other students about Git. I am trying to do something simple: Create a repository, add a file, commit changes and push to origin master.
I created a repository in my local machine, I added a file, I committed the changes the only problem now is that it gives me an error when I try to push to origin master.
I went to my Github account and I created a new folder because I thought that maybe that's what I need to do, however yesterday I was very overwhelmed by everything. I put up a whole presentation about Git using PowerShell for my students and I fell asleep.
Today I am trying to get back on track. I am in PowerShell again and I have absolutely no idea what to do.
How do I push to origin master?
Solution 1:[1]
The simplest answer for you will be to start over.
Create an empty repo on github, clone the repo down to your machine, make a change, and then push it back.
Github has excellent docs for how to do this, as well as how to do more complex things. There's really no reason to ask on SO.
Solution 2:[2]
The easiest way you can use is
Open your folder
Git Bash From there (Don't forget to connect your Git account before)
$ git status to see if there are any changes to the working directory and files located in untraceable and traceable
$ git add to change the state of the file/directory to staged
** $ git commit -m “message”** to insert snapshot data into git database, changemessagewith the message as needed, for exampleinitial commit.
Then
$ git remote add origin https://github.com/insertyourRepository to add remotes
$ git remote -v to see a list of remotes
$ git pull origin master to pull information from remote origin
$ git pull origin master to pull information from remote origin
There you go
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | aghast |
| Solution 2 | Ismail Ashari Sambara |
