4

Ok this is really frustrating me. I'm used to working with SVN, and am new to git. I had a folder called X in git already. A collobarator made changes to X and commited it, and I updated it. I made changes to it, and now I want to save it as X2 as a new folder. So I duplicated the X folder locally, and now I want to add this to github. So I did

cd X2 
git init 
git add X2 
git commit -m "changes" 
git push origin master

I also tried being in the parent directory where both X and X2 are located, then git add X2 and commit and push, but I keep getting "nothing to commit".

What am I doing wrong?

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
Snowman
  • 31,411
  • 46
  • 180
  • 303

3 Answers3

5

Why are you doing a git init before adding X2. Git init is done only when creating a repo. Also note that git add only adds files, not directories.

Apart from that git add X2 should work perfectly fine, when you are in root / parent. From within the folder itself do git add .

Quentin Pradet
  • 4,691
  • 2
  • 29
  • 41
manojlds
  • 290,304
  • 63
  • 469
  • 417
  • @Simon - where is it said that X2 is the root? Doesn't make sense – manojlds May 09 '11 at 01:16
  • Ok then after I do git add X2, what would I do? – Snowman May 09 '11 at 01:18
  • @bitmoe - Once you have done `git add X2`, do a `git status`. It should say something like `Changes to be comitted` and show X2 and its files – manojlds May 09 '11 at 01:20
  • Ok and now how do I push it to github? It commited succesful, but now I want to do git push origin master, but I get an error origin does not appear to be a git repo. What would be the right way to do this? – Snowman May 09 '11 at 01:24
  • Ok I was able to get X2 on github, but the folder name is not clickable online. Does that mean its still uploading? – Snowman May 09 '11 at 01:28
  • @bitmoe If you had done the `git init` as you had given in the steps in your question, can you make sure that you don't have a `.git folder in X2. If so delete it. – manojlds May 09 '11 at 01:40
  • You are adding everything without having defined a .gitignore file. – Adam Dymitruk May 09 '11 at 22:47
  • @adymitruk I said specifically that `git add .` when inside the folder ( X2) and the point of the question is to add everything in that folder. I did not say to do `git add .` from root. – manojlds May 09 '11 at 22:59
1

Commit a proper .gitignore file first. Then you can do a 'git add -A'. All the files you don't want will be skipped.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
0

Try using "git add ." this will add all the files in the current working directory to the stage (aka ready to be committed). Hope this works!

Kev
  • 187
  • 1
  • 11
  • `git add .` can be rather dangerous to use, especially if you're new to git. It's best to avoid using that if you don't know how to see what you're committing before you do the commit (hint: `git status` or `git gui`). – Tekkub May 09 '11 at 02:29