How to perform an automatic commit with predefined message using Magit?
up vote
4
down vote
favorite
I have a repository of org files which I mostly use for note taking and tracking, and I track it using git. I want to add a shortcut that would quickly commit all current content of the repository (both changed, new and deleted files) as a new commit with a predefined commit message (say "update"). How can I achieve this programmatically with magit?
Thanks in advance!
magit
add a comment |
up vote
4
down vote
favorite
I have a repository of org files which I mostly use for note taking and tracking, and I track it using git. I want to add a shortcut that would quickly commit all current content of the repository (both changed, new and deleted files) as a new commit with a predefined commit message (say "update"). How can I achieve this programmatically with magit?
Thanks in advance!
magit
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I have a repository of org files which I mostly use for note taking and tracking, and I track it using git. I want to add a shortcut that would quickly commit all current content of the repository (both changed, new and deleted files) as a new commit with a predefined commit message (say "update"). How can I achieve this programmatically with magit?
Thanks in advance!
magit
I have a repository of org files which I mostly use for note taking and tracking, and I track it using git. I want to add a shortcut that would quickly commit all current content of the repository (both changed, new and deleted files) as a new commit with a predefined commit message (say "update"). How can I achieve this programmatically with magit?
Thanks in advance!
magit
magit
edited 2 days ago
tarsius
15.8k23981
15.8k23981
asked 2 days ago
vmalloc
1383
1383
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
There are two parts to this task.
Figuring out how to do this on the command line.
$ git add .
$ git commit -m "the message"
Figuring out what Magit functions can be used to call Git commands.
You can either use commands or you can use low-level functions. I would recommend doing the latter, but looking at the definitions of the former might help locating the latter. The manual section named Calling Git would also come in handy.
Looking at that page you will learn that you should probably use
magit-call-git
and/ormagit-run-git
. The difference is that the latter also refreshes the current Magit buffer and the status buffer and doing that twice would be wasteful. So either use each function once or the latter twice and callmagit-refresh
explicitly.
(magit-call-git "add" ".")
(magit-call-git "commit" "-m" "the message")
(magit-refresh)
Now wrap that in a command and bind a key to it. You might even want to add the command to the commit popup by Customizing [this] Existing Popup.
Since I had trouble with this at first, if anyone wants to make a keybinding which executes multiple commands, you could do some eval magic, or use progn.
– Nathaniel Pisarski
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
There are two parts to this task.
Figuring out how to do this on the command line.
$ git add .
$ git commit -m "the message"
Figuring out what Magit functions can be used to call Git commands.
You can either use commands or you can use low-level functions. I would recommend doing the latter, but looking at the definitions of the former might help locating the latter. The manual section named Calling Git would also come in handy.
Looking at that page you will learn that you should probably use
magit-call-git
and/ormagit-run-git
. The difference is that the latter also refreshes the current Magit buffer and the status buffer and doing that twice would be wasteful. So either use each function once or the latter twice and callmagit-refresh
explicitly.
(magit-call-git "add" ".")
(magit-call-git "commit" "-m" "the message")
(magit-refresh)
Now wrap that in a command and bind a key to it. You might even want to add the command to the commit popup by Customizing [this] Existing Popup.
Since I had trouble with this at first, if anyone wants to make a keybinding which executes multiple commands, you could do some eval magic, or use progn.
– Nathaniel Pisarski
2 days ago
add a comment |
up vote
6
down vote
accepted
There are two parts to this task.
Figuring out how to do this on the command line.
$ git add .
$ git commit -m "the message"
Figuring out what Magit functions can be used to call Git commands.
You can either use commands or you can use low-level functions. I would recommend doing the latter, but looking at the definitions of the former might help locating the latter. The manual section named Calling Git would also come in handy.
Looking at that page you will learn that you should probably use
magit-call-git
and/ormagit-run-git
. The difference is that the latter also refreshes the current Magit buffer and the status buffer and doing that twice would be wasteful. So either use each function once or the latter twice and callmagit-refresh
explicitly.
(magit-call-git "add" ".")
(magit-call-git "commit" "-m" "the message")
(magit-refresh)
Now wrap that in a command and bind a key to it. You might even want to add the command to the commit popup by Customizing [this] Existing Popup.
Since I had trouble with this at first, if anyone wants to make a keybinding which executes multiple commands, you could do some eval magic, or use progn.
– Nathaniel Pisarski
2 days ago
add a comment |
up vote
6
down vote
accepted
up vote
6
down vote
accepted
There are two parts to this task.
Figuring out how to do this on the command line.
$ git add .
$ git commit -m "the message"
Figuring out what Magit functions can be used to call Git commands.
You can either use commands or you can use low-level functions. I would recommend doing the latter, but looking at the definitions of the former might help locating the latter. The manual section named Calling Git would also come in handy.
Looking at that page you will learn that you should probably use
magit-call-git
and/ormagit-run-git
. The difference is that the latter also refreshes the current Magit buffer and the status buffer and doing that twice would be wasteful. So either use each function once or the latter twice and callmagit-refresh
explicitly.
(magit-call-git "add" ".")
(magit-call-git "commit" "-m" "the message")
(magit-refresh)
Now wrap that in a command and bind a key to it. You might even want to add the command to the commit popup by Customizing [this] Existing Popup.
There are two parts to this task.
Figuring out how to do this on the command line.
$ git add .
$ git commit -m "the message"
Figuring out what Magit functions can be used to call Git commands.
You can either use commands or you can use low-level functions. I would recommend doing the latter, but looking at the definitions of the former might help locating the latter. The manual section named Calling Git would also come in handy.
Looking at that page you will learn that you should probably use
magit-call-git
and/ormagit-run-git
. The difference is that the latter also refreshes the current Magit buffer and the status buffer and doing that twice would be wasteful. So either use each function once or the latter twice and callmagit-refresh
explicitly.
(magit-call-git "add" ".")
(magit-call-git "commit" "-m" "the message")
(magit-refresh)
Now wrap that in a command and bind a key to it. You might even want to add the command to the commit popup by Customizing [this] Existing Popup.
edited 2 days ago
answered 2 days ago
tarsius
15.8k23981
15.8k23981
Since I had trouble with this at first, if anyone wants to make a keybinding which executes multiple commands, you could do some eval magic, or use progn.
– Nathaniel Pisarski
2 days ago
add a comment |
Since I had trouble with this at first, if anyone wants to make a keybinding which executes multiple commands, you could do some eval magic, or use progn.
– Nathaniel Pisarski
2 days ago
Since I had trouble with this at first, if anyone wants to make a keybinding which executes multiple commands, you could do some eval magic, or use progn.
– Nathaniel Pisarski
2 days ago
Since I had trouble with this at first, if anyone wants to make a keybinding which executes multiple commands, you could do some eval magic, or use progn.
– Nathaniel Pisarski
2 days ago
add a comment |
Thanks for contributing an answer to Emacs Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f46244%2fhow-to-perform-an-automatic-commit-with-predefined-message-using-magit%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown