How to perform an automatic commit with predefined message using Magit?
up vote
5
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
5
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
5
down vote
favorite
up vote
5
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 Nov 27 at 11:00
tarsius
15.9k23981
15.9k23981
asked Nov 27 at 7:29
vmalloc
1433
1433
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
8
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
Nov 27 at 13:13
Part 1 can be collapsed togit commit -a -m "the message"
– Andrew Swann
yesterday
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
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
Nov 27 at 13:13
Part 1 can be collapsed togit commit -a -m "the message"
– Andrew Swann
yesterday
add a comment |
up vote
8
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
Nov 27 at 13:13
Part 1 can be collapsed togit commit -a -m "the message"
– Andrew Swann
yesterday
add a comment |
up vote
8
down vote
accepted
up vote
8
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 Nov 27 at 11:00
answered Nov 27 at 10:14
tarsius
15.9k23981
15.9k23981
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
Nov 27 at 13:13
Part 1 can be collapsed togit commit -a -m "the message"
– Andrew Swann
yesterday
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
Nov 27 at 13:13
Part 1 can be collapsed togit commit -a -m "the message"
– Andrew Swann
yesterday
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
Nov 27 at 13:13
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
Nov 27 at 13:13
Part 1 can be collapsed to
git commit -a -m "the message"
– Andrew Swann
yesterday
Part 1 can be collapsed to
git commit -a -m "the message"
– Andrew Swann
yesterday
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