knocked loose
knocked loose

Reputation: 3304

Creating a new project in Git from terminal and later updating

So, my terminal only likes to sometimes update my git hub, what could be going on, or what am I doing wrong? I am using it to push a rails app in this example, here is what I typed to push to github.

$ rails new my-app
$ cd my-app
$ git init
$ git add .
$ git commit -m "Initial Commit"
$ git remote add origin https://github.com/Username/my-app.git
$ git remote -v
$ git push origin master

This works, to usually start a project, but it also requires me to make the repo on GitHub prior to the commit/push.

Is there a way I can create the repo as I push the new app?

My second part of this is pushing to add a commit to the project, for instance I typed this:

$ cd my-app
$ git add . 
$ git commit -m "Adds Posts Model, View, and Controller"

Which returns this text: 11 files changed, 75 insertions(+), 56 deletions(-) But I still have no new commit/update in the project on GitHub. No New Commit


I am using a 2014 MacBook Pro OSX 10.9.4

Upvotes: 0

Views: 36

Answers (1)

Tim
Tim

Reputation: 43314

Is there a way I can create the repo as I push the new app?

No. The terminal doesn't know what is on the receiving end of https://github.com/Username/my-app.git, and likewise github.com doesn't know that you will be pushing a repo and expect a repo to be made on demand. That just doesn't work like that.

Luckily it only takes a couple of minutes to create a project on github and reference it locally.

My second part of this is pushing to add a commit to the project, for instance I typed this:

$ cd my-app
$ git add . 
$ git commit -m "Adds Posts Model, View, and Controller"

Which returns this text: 11 files changed, 75 insertions(+), 56 deletions(-) But I still have no new commit/update in the project on GitHub.

A commit is a local operation. To get it to the remote on github, you need to push it:

$ git push origin master

for instance.

Upvotes: 2

Related Questions