9

I am trying to push some changes from cloud9 to a github repository but I am hitting a roadblock.

I can clone OK with ssh, and everything seems to be OK, I make my changes, save the changes in cloud9 (when I go back the changes are still there), then I do git commit and get:

no changes added to commit (use "git add" and/or "git commit -a")

but I just need to commit changes to an existing file not to add. So obviously when I try to git push origin master there's nothing to push.

I tried with multiple github repos and I get the same result.

What am I missing?

Any help appreciated!

P.S. Oh, btw I suck at git

JohnIdol
  • 48,899
  • 61
  • 158
  • 242

2 Answers2

17

The message shows that you are not adding changed/tracked files to commit.

Try with -am switch to ADD and Commit in one operation:

git commit -am "your message goes here"
git push
Tracker1
  • 19,103
  • 12
  • 80
  • 106
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
7

Git separates committing from adding changes. You first have to add all changes you want to appear in the commit:

#1: Add any new files as part of the commit
#   or use git add -p to interactively select hunks to stage
git add file1 file2 …

#2: Commit to local
git commit -m "Commit message goes here"

#3: Push your commit/changes to the host (github)
git push

You should now have all your changes on github.

Alternatively, you can do the commit, and add/modify in one line, this may include undesired files into your changeset.

#1 Add files commit to local
git commit -a -m "Commit message goes here"

#2 Push your commit/messages to the host (github)
git push
Tracker1
  • 19,103
  • 12
  • 80
  • 106
knittl
  • 246,190
  • 53
  • 318
  • 364
  • Thank you... did the command above, but didn't know about the push portion.. really green when it comes to git. – Tracker1 Apr 02 '12 at 20:09
  • @Tracker1: thanks for editing my answer, but I think it would have been better if you provided it as your own answer – you have re-written quite a bunch. Also, you removed the explicit `origin master` from `git push`, which often does the expected thing with fewer surprises – knittl Jun 15 '12 at 08:37
  • I removed the origin master, as in cloud9 to github, that option stopped working for me, while "git push" worked as expected.. :) Just the same, trying to be helpful with what was the most correct answer. – Tracker1 Jun 15 '12 at 22:26