tags:

views:

54

answers:

3

I am really new to git and I tried today to do my second ever commit of some new code to my repo. The thing is, I'm not sure if the git actually occurred.

Github says the last commit was 2 days ago.
When I type git add . nothing shows up.
When I go to github, the Rails3 file says loading commit data. I have been waiting for about 30 minutes but this is still there (and my commit wasn't all that big).

Is this typical behavior for git or could I have done something wrong? Also, how can I check to make sure in the future that the commits are happening when I try to do them?

A: 

Typical work flow would be:

git add *
git commit -am "message"
git push
colithium
git add . -A is better, you don't need the 'a' switch for the commit.
adymitruk
Wow. With your way you're actually typing an additional character. So why exactly is that "better" ? And a downvote... really?
colithium
It adds changes such as deletions as well. Sorry for the down vote. I'll vote it up. Not sure how "negative" the down votes are on SO.
adymitruk
I can't up vote :( It won't let me unless the answer is edited.
adymitruk
+2  A: 

If you are modifying files that are already tracked (ie. git status doesn't show any untracked files), I do this:

git commit -am "message"

git push

If you have new files or deleting files or directories then do this:

git add . -A

git commit -m "message"

git push

you can check to see if your commit worked with:

git log --stat

you can check to see if your commit got pushed to the remote server with:

git status

You should NOT see "Your branch is ahead of 'xxxxxx' by 1 commit" where xxxx will be something like origin/master.

Hope this helps.

adymitruk
Very useful, thank you adymitruk. +1
sscirrus
+4  A: 

First, although you're using Github, make sure you understand that you're interacting with your local repository first. (Github isn't involved until you push.)

The most important command to find out the status of your repository is git status. This shows files that are:

  • known to git and scheduled for commit (i.e. git add has been run)
  • known to git and modified
  • unknown to Git

Once you make a commit, the files will disappear from the git status display. At that point, you can use git log to show the log of commits made in your repository (most recent first).

Greg Hewgill
Greg, this entire answer was incredibly helpful to me. Thank you! Glad to see you and your family are safe from the recent quake.
sscirrus