问题描述
我使用浏览器直接在GitHub上创建了一个repo,而不是使用git bash将repo克隆到我的机器上,我可以使用readme文件做bash测试。
我一直在致命:当运行git --work-tree = yourSrcFolder add时,必须在工作树中运行此操作。
正在寻找和一些线索,但4小时后准备放弃使用Git。
如果你看看第一个链接,我把这个问题放在4个upvotes的答案中,我试图完成他所说的话:这样,你可以分开你的初始源文件夹,从你的Git工作树开始,这就是为什么我试图使用--work-tree = yourSrcFolder add,所以我希望这给了downvoters一些推理的动机。
test.txt
的文件添加到您的git仓库中。- 移动它进入您的版本库目录
- 运行
git add test.txt
code> git commit -m将测试文件添加到回购站 - 将您的修改推送到远程服务器
git push
I created a repo directly on GitHub using by browser, than using git bash cloned the repo to my machine, I was able to do a test commit with bash using the readme file.
I keep getting fatal: This operation must be run in a work tree when running git --work-tree=yourSrcFolder add .
Was looking here and here for some clue but after 4 hours ready to give up on ever using Git.
If you look at the first link I put in this quesion the answer with 4 upvotes, I was trying to do exactly what he said: "That way, you keep separate your initial source folder, from your Git working tree.", which is why I was trying to use --work-tree=yourSrcFolder add, So I hope that gives the downvoters some reasoning behind my motives.
Simply move any file you wish to add into the repo directory, then add them to the git tracking.
Example: suppose you want to add a file named test.txt
to your git repo.
- Move it into your repository directory
- run
git add test.txt
- commit the file using
git commit -m "Added test file to the repo"
- push your modification to the remote server
git push
这篇关于如何使用git从其他目录添加文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!