-1

I have been trying to learn to use github, it has been fine until I used the git gui. It seems to have done something to something I don't yet understand, when trying to commit I get

Your branch is ahead of main/master by 1 commit [..]

It then proceeds to list the entire contents of my apache directory under 'untracked files'. Main was a branch I created because I had made a mistake and didn't know how to remove things. I have tried all of the solutions I could find on google, but none worked. This problem is incredibly frustrating, but probably due to my own ignorance. If someone could point me in the direction of a github tutorial that would explain the concepts I am missing to me, I would be grateful. A quick solution would also be fine. Many thanks in advance. I apologise if this is a question that has been asked times before.

EDIT: git status:

# On branch master
# Your branch is ahead of 'main/master' by 1 commit.
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   deleted:    htdocs/main.html
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   bin/
#   cgi-bin/mappings.txt
#   conf/
#   error/
#   file
#   htdocs/index.html
#   icons/
#   include/
#   lib/
#   logs/
#   manual/
#   modules/
#   test/ no changes added to commit (use "git add" and/or "git commit -a")
user1034533
  • 1,054
  • 9
  • 9

1 Answers1

1

So, I'm not really sure how your repository got in this state, but there are a few things worth note:

  1. What you saw when you attempted to commit wasn't an error, it was just the current state of the repository. (Of course, I'm assuming you saw the full status output when you attempted to commit as well. That's SOP.)

  2. The reason you're seeing the output about the current state of the repository when you attempt a git commit is because according to the status command above no changes are staged for commit. To stage changes for a commit, you need to git add them. Or, if you want to commit all modified files you could just run git commit -a to commit all tracked, modified files.

  3. In this sample it looks as though something has gone awry with your repository and everything has become untracked. I'm not sure how this happened, but the immediate solution is to run git add * to track everything and then git commit to do the commit.

  4. However, If there is a repository already on github that this repository was, at one time, linked to - then you might also consider re-cloning that repository and making your changes in the fresh copy. Sometimes, it's quicker to start with a clean slate. Doing that will fix your immediate problem without having to reset the remote repository from scratch, too.

  5. To answer your question about possible resources, try reading through the Github Help Pages and the official Git Community Book. I've been using git for less than a year, and I've found both resources to be incredibly helpful.

If there's anything that's unclear, just leave me a comment and I'll do my best to clarify. Git is a tricky beast some days. :)

Matt Farmer
  • 709
  • 4
  • 13
  • That's what I initially thought, though I was hesitant because I assumed using add would add all of the apache files to the repository. Could you clarify whether this is the case or not? – user1034533 Nov 07 '11 at 23:30
  • Well, yes. Using `git add *` will add everything. You can, however, limit the add to a particular folder or set of files. i.e. `git add htdocs` – Matt Farmer Nov 07 '11 at 23:39
  • Aha! That got me past the commit stage! How would I remove a file I added by accident? – user1034533 Nov 07 '11 at 23:43
  • Try `git rm --cached filename` as seen here: http://stackoverflow.com/questions/1143796/git-remove-a-file-from-the-repository-without-deleting-it-from-the-local-filesy – Matt Farmer Nov 07 '11 at 23:53