我正在写一个Lua脚本,它创建一个目录,在其中创建一些文件并初始化git,将这些文件添加到它并最终提交所有内容。然而,从Lua内部没有办法使用cd
(你可以,但它不会有效果),所以我想知道是否有可能git init
一个目录,git add
某些文件,最后是git commit -a -m "message"
,所有的工作目录都是上面的目录所需的目录。编辑:-C
作品,谢谢大家。对于任何人想知道,在呼叫os.execute
结束后,在Lua,cd
“重置”。因此,os.execute("cd mydir"); os.execute("git init");
将无法按预期工作。要使其起作用,请使用os.execute("cd mydir; git init;");
。git init,添加,从不同的目录提交
2
A
回答
3
通过关于-CI评论下面的提示做:
git init newStuff
Initialized empty Git repository in c:/fw/git/initTest/newStuff/.git/
作出的dir Newstuff文件git的回购协议(我已经创建)
然后我说两个文件Newstuff文件,并从它的父母使用-C
git -C newStuff/ status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
new1
new2
nothing added to commit but untracked files present (use "git add" to track)
我看到新的文件。上壳
git -C newStuff/ add .
git -C newStuff/ status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: new1
new file: new2
git -C newStuff/ commit -m"initial"
[master (root-commit) bfe387b] initial
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 new1
create mode 100644 new2
2
例:新增并提交它们
#!/bin/sh
dirPath=some/dir/path
mkdir -p $dirPath
touch $dirPath/newFile
git init $dirPath
git -C $dirPath add .
git -C $dirPath commit -a -m "Initial commit"
git -C $dirPath log
相关问题
- 1. git添加子目录内容提交
- 2. git的init不会创建.git目录
- 3. 主目录中的Git Init - 现在无法提交更改
- 4. 将Git提交到目录
- 5. 无法从Virtualenv添加/提交git
- 6. Git从旧提交添加代码
- 7. GIT添加或提交?
- 8. git从存储库的子目录中限制“添加”和“提交”
- 9. git从目录中添加文件
- 10. Git添加没有目录?
- 11. SVN和不同的IDES(提交+添加)
- 12. Git提交一个目录,而不是在git路径
- 13. git不会'添加'子目录
- 14. 如何添加和提交文件中的一个Git仓库,而在不同的目录
- 15. git-svn提交一个目录?
- 16. Git init初始化在不同的目录而不是当前的
- 17. 将Git远程添加到不同目录
- 18. Git,添加更改提交,添加和提交标记之间的区别
- 19. 从以前的所有git提交中删除.idea目录
- 20. 如何在JIRA中添加git提交
- 21. 添加svn提交到git repo
- 22. repo init特定提交
- 23. 在git中推送不同的提交
- 24. 如何使用GIT将同一项目的两个不同提交提交到不同的本地文件夹
- 25. 使用git提交一个名为“.git”的目录
- 26. 目录更改后不会提交
- 27. Git to svn:添加提交日期以记录消息
- 28. Git记录所有,显示当前的提交方式不同
- 29. git提交新文件,即使没有添加和提交
- 30. Git预提交钩子在提交后添加文件
所以混帐回购协议是在LUA脚本的位置的子目录。那是对的吗? –
@代码学徒准确。 – user6245072
[这个问题](http://stackoverflow.com/questions/3769137/use-git-log-command-in-another-folder)特定于'git log',但看看' - git-dir '标志适用于其他命令。 –