How to run git commit -m '...'
command from another directory?
I edit my file:
vim /home/.../myFile
I add it using:
git add /home/.../myFile
But now, how can I commit the changes?
git commit -m '...' ???
Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed. Enter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository.
In order to get commits from the other repository, You'll need to add the other repository as a remote, then fetch its changes. From there you see the commit and you can cherry-pick it.
git add -A && git commit -m' once and every time I just type: git ac 'comment' :) git config --global alias. add-commit "! git add -A && git commit" (i.e. double quotes instead of single quotes) is what works on Windows.
You can use git -C <path>
.
From https://git-scm.com/docs/git/2.4.4
git -C <path>: Run as if git was started in <path> instead of the current working directory.
You can also use the environment variables $GIT_DIR
and $GIT_WORK_TREE
to the same effect as --git-dir
and --work-tree
These are the steps to commit a file when you are in another directory:
git --git-dir=/path/to/my/directory/.git/ --work-tree=/path/to/my/directory/ add myFile
git --git-dir=/path/to/my/directory/.git/ --work-tree=/path/to/my/directory/ commit -m 'something'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With