I am writing a Lua script that creates a directory, creates some files inside of it and initializes git, adding those files to it and finally committing everything. However there's no way to use cd
from inside Lua (you can, but it won't have effect), so I wonder if it's possible to git init
a directory, git add
some files and finally git commit -a -m "message"
, all while the working directory is the directory above the desired directory.
Edit: -C
works, thanks everyone. For anyone wondering, in Lua, cd
"resets" after the call to os.execute
ends. So, os.execute("cd mydir"); os.execute("git init");
won't work as expected. To get it to work, use os.execute("cd mydir; git init;");
.