121
votes
Accepted
Add change to a previous commit with Magit
Let's pretend for a moment that you want to add something to the HEAD commit, i.e. "the second commit B" in your example.
The commit popup on c features a binding "a Amend". Pressing that key will "...
37
votes
Accepted
How can I use emacs with git within the terminal?
When you run git config --global core.editor emacs -nw, your shell splits the command line into words before invoking git. Git thus sees "emacs -nw" as two separate arguments. It only needs one to put ...
35
votes
Accepted
How to automatically sign commits with magit?
In Magit commits are created using the committing popup (c). That popup would therefore be a good place to start looking for gpg support. If you do that, then you will find this:
=S Sign using gpg (--...
28
votes
Accepted
Magit - Undo last commit - History Manipulation
You can use magit-reset (bound by default to x). The
commit at point will be used as the default for the prompt, but you
can enter any revision value you'd like ("HEAD~" here).
The resetting ...
24
votes
How to automatically sign commits with magit?
Try this in your $HOME/.gitconfig or your .git/config
[user]
email = YourEmail
name = YourName
signingkey = XXXXXXXX
[commit]
gpgsign = true
Then just commit as usual.
19
votes
Untrack file without deleting it?
In the Magit buffer, hit K (uppercase k) on the file. It works with magit 2.3; I don't know for earlier versions.
18
votes
Accepted
DOOM Emacs: Error running hook "global-git-commit-mode" because: (void-variable transient-base-map)
It seems that some magit dependencies break with Emacs 28, as the function defvar-keymap is only added in Emacs 29. The solution is to pin an older version of the packages, as Doom currently does not ...
14
votes
How to merge Git conflicts in Emacs
If you happen to use Spacemacs, I'd recommend activating "smerge-transient-state", which brings up a hydra menu with all possible smerge commands.
To do that, simply call M-x spacemacs/...
13
votes
How to change options passed to git vc-annotate?
With Emacs 25.1 you can pass options to git blame using the vc-git-annotate-switches variable:
(setq vc-git-annotate-switches '("-w"))
13
votes
Accepted
How do I set the upstream branch to push a local branch to in magit?
There are several ways to set the upstream, while pushing or without pushing at the same time.
If magit-push-current-set-remote-if-missing is non-nil (the default), then you will see something like:
...
13
votes
Accepted
Magit extremely slow in Windows. How do I optimize?
I have actually done rather a lot of research on this and fundamentally the problem is that git for windows sucks
This is the upstream bug: https://github.com/git-for-windows/git/issues/596 and it ...
13
votes
Accepted
How can I make 'git diff' aware of Emacs Lisp functions?
Is it possible to make Git aware of how to identify a useful line to use for the @@ line?
Yes, quoth section "Defining a custom hunk-header" in man 5 gitattributes:
Defining a custom hunk-...
12
votes
Accepted
How can I do a git diff on the current file with magit?
Firstly, make sure you're aware of https://stackoverflow.com/a/17799517
If you want a Magit diff buffer for the current file, you can call magit-diff-buffer-file directly, or use the "diff" option (d) ...
12
votes
Accepted
How do I visit a file on a different branch?
So I was confused because the options to choose from for C-x v ~ only showed older revisions of the file on this particular branch, but you can in fact specify a branch and have that file shown.
Ie. ...
10
votes
Accepted
Merge specific files with magit
As noted in many answers to the question you have linked to and even more so in comments on those answers, git checkout source_branch -- <paths>... does not perform a merge.
Never-the-less ...
10
votes
Accepted
Magit remove local branches that were merged into another branch
The refs buffer has options to filter to merged branches.
Quoting C-hig (magit)References Buffer:
‘y’ (‘magit-show-refs’)
This command lists branches and tags in a dedicated buffer.
However if this ...
9
votes
Accepted
Delete multiple branches in using magit from `helm-mode-magit-branch-delete`
The doc-string you quote talks about marking multiple branches in a Magit buffer, not during Helm completion.
You can show a buffer which lists all branches and tags using y. In that buffer you can ...
8
votes
Accepted
Magit how to cancel running git process
You can use M-x magit-process-kill in the Magit process buffer ($, or M-x magit-process-buffer jumps to process buffer for the current repository).
magit-process-kill is an interactive Lisp closure ...
8
votes
Accepted
Function of org-clock-save.el file and Git related question
The file org-save-clock.el is used to store two kinds of information:
the active clock if emacs is shut down while a task is active
(gets stored in org-clock-stored-resume-clock)
the history of the n ...
8
votes
magit-stash-create: Cannot save the current index state
This could also be due to not having configured git properly:
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
8
votes
Accepted
Magit - How do I sync my feature branch with the latest master without checking out master?
There's no need to checkout a local copy of master. You just need to fetch the current ref for the remote origin/master branch (assuming the appropriate remote is named origin), and then use that.
...
8
votes
Accepted
How to install latest version of org mode?
[As requested, expanding the comment into an answer]
The main idea is that you need to make sure that Org mode is set up, using the new bits that you downloaded only. Emacs comes with a version of ...
7
votes
Accepted
Indicate whether file has uncommited changes in mode line
Well, vc does that by default. From its documentation (emphasis mine):
When you visit a file that is under version control, Emacs indicates
this on the mode line. For example, ‘Bzr-1223’ says ...
7
votes
Magit: how remove push branch?
Bring up the magit status window with M-x magit-status or whatever shortcut key binding you use. type b to bring up the branch menu. type p to cycle through the push options enough times to get to ...
7
votes
Accepted
What is the equivalent of doing a plain `git reset <sha>` in magit?
Use x or X s to do so.
Using the X prefix has the benefit that it shows you all the available git reset variants.
This is also documented in the Resetting section of the manual.
7
votes
Accepted
How to properly use Magit Fixup?
f just creates the fixup! commit. You wanted the upper-case F -- that ("Instant Fixup") is the variant which automatically performs the rebase after creating the fixup! commit.
You can ...
6
votes
Set author per repository
One way to do this is to set the author configuration in .git/config in each repository, in the same format as in ~/.gitconfig, i.e.:
[user]
name = My Name
email = [email protected]
6
votes
Set author per repository
you can do this with one-time git configuration. you can use it for email and so on, but also for using a different ssh key:
in ~/.gitconfig:
[includeIf "gitdir:~/work/"]
path = .gitconfig_work
in ~...
6
votes
Enable smerge-mode for already opened file
This is what I have in my init file :
(defun smerge-try-smerge ()
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil t)
(require '...
6
votes
How do I make Magit only show diff for unstaged changes?
Try M-x magit-diff-unstaged, also available in the diff popup (d u).
If you've globally bound magit-dispatch-popup to some key,then you can use that followed by d u to get to the unstaged diffs ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
git × 262magit × 150
version-control × 16
vc × 15
microsoft-windows × 9
mode-line × 9
org-mode × 8
dired × 7
ediff × 7
spacemacs × 6
helm × 6
github × 6
init-file × 5
projectile × 5
diff × 5
vc-mode × 5
hooks × 4
emacsclient × 4
shell-command × 4
grep × 4
osx × 3
tramp × 3
files × 3
ssh × 3
bash × 3