问题描述
试图提交一些更改。我使用 git add
来添加任何可能使用通配符 *。js
创建的新javascript文件。然后我提交了更改并推送到github:
git add * .js
git commit -mstuff
git push github master
当我检查github时,我所编辑的所有文件都是空白的。他们在那里,只是空的。
然后我试着再次提交,但GIT说所有内容都是最新的。
然后我回头注意到,在我做了 git commit -mstuff
之后,GIT显示了一条消息即使我刚刚使用通配符添加它们,一堆我的.js文件仍未上演: git add * .js
。这是我尝试提交时显示的消息。
#在分支主机上
#没有为commit提交的更改:
#(使用git add / rm ...更新将要提交的内容)
#(使用git checkout - ...放弃工作目录中的更改)
#
#modified:src / static / directory1 / js / module1 / file1.js
#modified:src / static / directory1 / js / module1 / file2.js
#modified:src / static / directory1 / js / module2 / file1.js
为了解决这个问题,我必须在执行 git add
:
git add src / static / directory1 / *。js
这看起来很奏效,因为在我再次提交并且被推送到github后,文件就在那里:
git commit -mstuff
git push github master
在这里继续,为什么我必须浏览几个目录才能找到外卡工作?
谢谢!
使用find命令:
find。 -name'* js'-exec git add {} \;
在没有exec的情况下运行它会给你正在处理的文件列表;所以,很容易根据自己的喜好调整这个命令。
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.
这篇关于“git add * .js”没有在子目录中添加文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!