add git 目录及子目录_“git add * .js”没有在子目录中添加文件

Was trying to commit some changes. I used git add to add any new javascript files that I may have created using the wildcard *.js. Then I committed changes and pushed to github:

git add *.js

git commit -m "stuff"

git push github master

When I checked github, all the files that I had been editing were blank. They were there, just empty.

I then tried to commit again, but GIT said that everything was up to date.

Then I went back and noticed that after I did git commit -m "stuff", GIT displayed a message saying that a bunch of my ".js" files were not staged even though I had just added them using the wildcard: git add *.js. This is the message that was displayed when I attempted to commit.

# On branch master

# Changes not staged for commit:

# (use "git add/rm ..." to update what will be committed)

# (use "git checkout -- ..." to discard changes in working directory)

#

# modified: src/static/directory1/js/module1/file1.js

# modified: src/static/directory1/js/module1/file2.js

# modified: src/static/directory1/js/module2/file1.js

In order to fix this I had to go down a few directories when doing my git add:

git add src/static/directory1/*.js

This seemed to worked, because the files were there after I committed again and then pushed to github:

git commit -m "stuff"

git push github master

What was going on here, why did I have to navigate down a few directories to get the wild card to work?

Thanks!

解决方案

An alternative is to use the find command:

find . -name '*js' -exec git add {} \;

Running that without the exec will give you the list of files that you are working on; so, it is easy to tune this command to your liking.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值