30
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 ...
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 ...
15
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/...
14
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. ...
11
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"
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 ...
10
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 ...
9
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
Magit git diff between two specific SHAs
Use the diff range command with the .. syntax:
dr SHA#1..SHA#2
Refer to the git diff man page:
git diff [--options] <commit> <commit> [--] [<path>...]
This is to view ...
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
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
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 ~...
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
Show a list of names for all git projects
One existing approach is: https://magit.vc/manual/magit/Repository-List.html#Repository-List. After setting magit-repository-directories, you can use M-x magit-list-repositories to display these ...
7
votes
How to ask magit to use external diff and merge tools?
Magit does not support invoking external diff tools and it will be a very long time until I get around to implementing such support because I am focused on improving the internal tools instead so that ...
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.
6
votes
Accepted
Cannot get Magit to show the commit signatures in the log
The --show-signature argument can be selected in the log popup but it is not actually passed to git log. Instead %G? is added to the value of the --format= argument.
That (%G?) causes some letter to ...
6
votes
Accepted
How to use `--no-edit` flag in a `git commit --amend` process inside magit?
That's exactly what c e (“extend”) does.
And conversely, to change the commit message without amending the commit with the staged changes, there's c w (“reword”).
5
votes
Magit how to use ssh key rather than being prompted for password
The issue was that the remote url was set to https rather than ssh
following these steps fixed the issue https://help.github.com/articles/changing-a-remote-s-url/
5
votes
Magit how to use ssh key rather than being prompted for password
Edit ~/.ssh/config so that it contains the following:
Host github.com
IdentitiesOnly yes
IdentityFile ~/.ssh/your_ssh_key
Then whenever magit asks git to ask ssh to talk to github.com, ssh will ...
5
votes
Magit git diff between two specific SHAs
If both commits are near each other in some Magit buffer, then it might be convenient to mark them using the region and then pressing d d. With such an active region "diff dwim" assumes that you want ...
5
votes
Accepted
Unable to use git in shell inside a buffer
M-x shell is a dumb terminal, whereas it looks like the commands you're using expect a more fully-featured terminal. This is what the "WARNING: terminal is not fully functional" messages are about.
...
5
votes
Accepted
Advanced git grep from within emacs
I found the answer to my own question. It seems M-x grep is pretty powerful, in that it can handle any "grep like" shell command's output.
So you can do
M-x grep
# it will ask you for the command, ...
5
votes
How do I stop Emacs micro-stuttering and high CPU utilization caused by background calls to git?
Solution
The problems turned out to be caused by the customization variable auto-revert-check-vc-info.
If this setting is active, the version control software – git in my case – will be invoked ...
5
votes
Accepted
magit blame: how to go to the commit my cursor is currently on
Enter magit blame mode ('M-x magit-blame'), then place your cursor on a line within that commit and press 'b', then 'b' again.
5
votes
How can I do a git diff on the current file with magit?
If you have ediff set up properly (and you should! it's awesome), then you can use M-x ediff-revision to run ediff for the current file against any of its revisions in Git, or in whatever VC system ...
5
votes
How can I tell magit to ignore specific modified files?
You can tell git to temporarily ignore changes to a certain file using:
git update-index --assume-unchanged <file>
and later you can undo that using:
git update-index --no-assume-unchanged &...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
git × 275magit × 155
vc × 20
version-control × 16
microsoft-windows × 11
mode-line × 9
org-mode × 8
dired × 8
ediff × 8
spacemacs × 6
helm × 6
projectile × 6
diff × 6
github × 6
vc-mode × 6
init-file × 5
hooks × 4
emacsclient × 4
ssh × 4
shell-command × 4
grep × 4
package × 3
osx × 3
tramp × 3
files × 3