开发者

Why is there "nothing to commit" after I added my new directory?

开发者 https://www.devze.com 2023-03-04 00:37 出处:网络
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 c

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?


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 .


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


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号