Questions tagged [git]
is for Emacs support of Git, the distributed version control system. Emacs `version-control` feature supports many systems besides Git. Additional extensions, such as `Magit`, also provide extensive Git support. Therefore use additional tags besides `git` for Git related questions.
278 questions
1
vote
1
answer
105
views
Automatically adding Signed-off-by trailers to Git commits
I occasionally write Git commits for a project that requires all commits to carry a Signed-off-by trailer, to signal compliance with the Developer Certificate of Origin.
I frequently forget to add ...
0
votes
1
answer
66
views
magit mark files to stage
Is there a way to mark files to stage with magit?
I want to pick only specific changes to be staged all at once, so that when I finally run magit-stage-file, all those marked changes get staged ...
0
votes
0
answers
68
views
Not show Git branch name in modeline (Windows)
Given:
Emacs 28.1
Windows 11
git version 2.47.1.windows.1
Here my init.el
;; https://github.com/Malabarba/smart-mode-line
(use-package smart-mode-line
:ensure t
:config
;;(setq sml/theme 'light)
...
2
votes
1
answer
177
views
Deferring `magit` load without breaking highlight in `git-commit`
I am interacting with git via a set of zsh functions/aliases I've grown over the years, so I don't typically need magit. In fact, I only have magit installed to provide syntax highlight for when git ...
0
votes
2
answers
64
views
Adding automatic diffstat for last change to magit status buffer
I would like my Magit status buffer to display a diffstat of recent changes at the bottom. Ideally, this would be like the diffstat shown by git pull when the merge.stat option is true—a diffstat ...
1
vote
1
answer
124
views
Git difftool on windows causing "Non-hex character used for Unicode escape: s (115)"
I want to use ediff as difftool for git.
I copied the configuration for git from here:
[difftool.ediff]
cmd = emacs -Q --eval \"(ediff-files \\\"$LOCAL\\\" \\\"$REMOTE\\\")...
0
votes
0
answers
86
views
vc-dir push : how to setup the gitconfig
I am using vc-dir for simple git tasks and I am happy with it but for the moment I still need to push outside of emacs and I would like to fix this. When I push (C-x v P), I get the following error: ...
0
votes
1
answer
129
views
Updating ssh-agent state from within Emacs
I have recently switched from launching Emacs from the terminal (i.e. emacs --init-directory "path/to/my/init") to launching it from a universal keybinding (i.e. super-e). This has had the ...
0
votes
1
answer
58
views
`vc-revision-*` for deleted file
I sometimes want to look at the last version of a deleted file. Normally for a file that still exists in the repo, I cant do Ctrl+x v ~ (bound to vc-revision-other-window). But that has no mechanism ...
1
vote
1
answer
83
views
How to delete a git branch locally and remotely in version-control?
In the manual pages about version control I find the instructions on how to create and switch to branches, also for Git repositories. But I can't find information on how to delete a branch – both ...
0
votes
1
answer
164
views
In Magit how can I see the difference a commit make to a file?
In Magit it is easy to see what difference a local file has compared to its checked-in version (HEAD).
However once I received changes from others (via magit-pull), I would like to see what changes ...
0
votes
1
answer
89
views
What is the equivalent of doing `git reset <file>` / `git reset` with the shipped vc?
I sometimes want to unstage changes. From the console I can use git reset or git reset <file>.
I couldn't find anything related in the docs or via C-x v C-h for vc, but it seems that this should ...
0
votes
1
answer
91
views
File Buffer Auto Revert Mode Not Working When Buffer Mode Has Changed And Git Rebasing
Version Details: Emacs 28.2 On Debian 12
Steps to reproduce:
I am editing Groovy files in a Git workspace. When I load the files they come up as fundamental so I switch to java-mode. All works as ...
4
votes
1
answer
372
views
When merging conflicts in the smerge mode, how to select "mine" for all conflicts in the file?
When merging conflicts In smerge mode, how to select "mine" for all conflicts? At the moment I only know how to do it one by one with smerge-use-lower or C-c ^ l.
Update: a possible solution ...
3
votes
2
answers
108
views
Cannot commit parts of *vc-diff* on Microsoft Windows
Emacs has a beautiful feature: in the *vc-diff* buffer (generated by vc-diff either by C-x v = in a file buffer or by = in a *vc-dir* buffer), kill unwanted hunks with k (i.e., diff-hunk-kill) and ...
0
votes
1
answer
137
views
Navigating through the vc revisions of a file
There is any command/package that allows me to move back and forth through the vc history of a file, updating the buffer to display the previous/next revision of that file?
Let's say I have a file ...
0
votes
1
answer
61
views
Calling git commit from shell-command results in incorrect log message
I implemented the following to git commit after a file is saved. It works, I think, but the commit message, rather than being empty, is the literal value ''. This is the case whether or not I have any ...
0
votes
1
answer
121
views
xref-find-apropos vs vc-git-grep
I 've been using git specific commands from helm (I think it internally uses vc-git-grep
I find xref-find-definitions work very well. and wonder how xref-find-apropos compare with vc-git-grep
I coulnd'...
3
votes
2
answers
463
views
How do I set package-vc-selected-packages to use a specific commit?
Emacs 29.1 introduced new functions to install packages directly from source.
Configuring it to download from the latest commit works fine, but I can't find how to download from a specific commit ...
0
votes
1
answer
324
views
prevent symbolic link follow from git repo HOWTO
I have git repo here: ~/git/myrepo/
then I do:
ln -s ~/external_dir ~/git/myrepo
emacs follows symbolic link when opening the file: ~/git/myrepo/external_dir/somefile.txt
I'd like to prevent it, ...
1
vote
1
answer
466
views
How do I pop/apply selecting a file or hunks from file in stash using Magit?
I need to select some files or hunks in one file in existing stash entry using Magit, and then apply or pop them. How can that be done?
The git command for a file (with 0 replaced by the relevant ...
0
votes
1
answer
87
views
Modern Emacs keeps opening related file from vc-diff buffer
Initially I opened Lags when navigating vc-root-diff buffer and the cause of slowness was Emacs opening referenced files by diff.
Back then I used Emacs 27.1. Now I'm on Emacs 28.2 and previous ...
0
votes
1
answer
25
views
git question: Why does git fetch not provide a fully updated local repo of Emacs?
More than a year ago I cloned Emacs:
git clone git://git.savannah.gnu.org/emacs.git
and since always kept it on date with
git fetch git://git.savannah.gnu.org/emacs.git
Well, at least I thought that ...
2
votes
1
answer
145
views
Disable yes/no prompting in git-gutter?
I use git-gutter to keep track of git changes in my buffer while editing.
I created this hydra to speed up commits a bit more (when I don't feel like using magit - often because this "takes me ...
0
votes
2
answers
3k
views
How do I use Emacs editor in Git Bash terminal on a Windows machine?
I am currently using vim editor on Git Bash terminal running in a Windows machine, but I want to switch over to Emacs editor. It is returning bash: emacs: command not found . Do I need to install the ...
8
votes
1
answer
2k
views
DOOM Emacs: Error running hook "global-git-commit-mode" because: (void-variable transient-base-map)
Full error (on the bottom line): Error (doom-first-file-hook): Error running hook "global-git-commit-mode" because: (void-variable transient-base-map)
Hello! I'm running this on an M1 chip ...
0
votes
0
answers
36
views
Git commands with emacsclient expect vim input
I'm using emacsclient. When I use git glog or git rebase -i in a shell within my emacs session, I see output that expects me to be able to scroll (and to exit with :q). I cannot exit this buffer, ...
1
vote
1
answer
781
views
How to checkout a Pull Request locally using Magit interface?
Suppose someone (not me) submitted a Pull Request on GitHub.
Locally, I would like to run that work. Hence, I need to have the code locally. Following this documentation, I can achieve that in the ...
0
votes
1
answer
349
views
Magit aborts commit that runs with husky precommit hook but the commit works on the command line
I'm a bit a bit stumped by an annoying problem that I'm having with magit. I'm working in a monorepo (lerna) repository that uses husky to run a precommit hook. The hook runs on packages that have ...
0
votes
1
answer
52
views
crux-delete-file-and-buffer (Please commit or undo your changes before deleting)
I try to run crux-delete-file-and-buffer, but it gives me:
vc-delete-file: Please commit or undo your changes before deleting
Why can't it just delete it?;)
0
votes
1
answer
45
views
How to change the commit associated to a tag on a branch that has already been pushed to GitHub?
I have attributed a tag called origin/v0.4.9 for a specific commit on a GitHub Pull Request. I thought the PR was simple, stable, and "a certainty" to be merged really fast. I was wrong.
I ...
1
vote
1
answer
66
views
When a merge-conflict happens and two options are shown, what is the magit command that allows the user to easily pick one of them?
Suppose a merge conflict happens. There are two options shown the upper (in red) and the lower (in green):
I would like to avoid complex ediff-mode stuff to pick one. I have seen some tutorial where ...
0
votes
1
answer
318
views
Why can't I solve this merge conflict on Magit?
I am working on a feature via Pull Request. While I was working, main branch evolved.
Now, I want to put my changes on the Pull Request on top of latest main branch. This means I want to rebase.
Hence,...
0
votes
1
answer
76
views
Changing the name of newsrc.eld
Is it possible to change the name of Gnus' newsrc.eld?
My use-case is that I want to use the same Emacs setup on various machines, which are either work machines or private machines. The Gnus ...
0
votes
0
answers
52
views
What causes an error "git not found" for each org-agenda file when building org-agenda-list?
I have emacs 28.1 on my phone in F-Droid.
When I start any org-agenda population command like org-agenda-list or org-agenda-list-stuck-projects the list shows up, but also shows up this error message ...
0
votes
1
answer
57
views
In Magit, is it possible to know when an unstaged change happened? How to find that information?
I have a repository under version control and I am using Magit as an interface to git.
I can see one unstaged change in a file after executing magit-status (C-x g). This means the file was changed and ...
0
votes
0
answers
48
views
counsel-git-grep: why does it ignore .gitignore paths?
Currently there is an issue (or else I can't figure it out) with counsel-git-grep-function: why does this function not ignore the files in .gitignore when searching? It would be a useful function if ...
4
votes
1
answer
1k
views
How to do a "git fetch --all --tags" in Magit?
I would like to pull changes from an upstream repository. More specifically, I would like to pull all the tags that were introduced. On the terminal, I can do:
$ git fetch --all --tags
On Magit, ...
2
votes
1
answer
287
views
How to force a git checkout revision in Magit if there are unstaged changes?
On the terminal, in a repository with unstaged changes, I can do:
~/projects/introduction-to-clojure$ git checkout -f 3.7
Branch '3.7' set up to track remote branch '3.7' from 'origin'.
Switched to a ...
0
votes
1
answer
76
views
Which option should I choose when executing "i' (Ignore) on Magit? Should Gitignore be shared in private, at the top level or in subdirectory?
I keep my emacs init file under version control. See the GitHub.
I have the things installed from ELPA also unver version control. Which is annoying. After executing Magit status, I have:
Head: ...
2
votes
1
answer
809
views
Make Magit ignore certain files already added to git and to .gitignore
This question is related to this previous question.
These two files below are under version control which causes some inconvenience in magit-status:
Unstaged changes (2)
modified .emacs.d/projectile-...
6
votes
1
answer
3k
views
How to properly use Magit Fixup?
I am trying to use the Fixup feature on Magit. I will list a recipe to what it is happening:
(i) - I have a project under version control.
(ii) - My first commit is:
1f61d09 * first commit: add file
...
0
votes
1
answer
178
views
Insert a string to the git-commit message buffer
I have configured git to use emacs as editor for writing commit messages (with (start-server) in my init.el). I now want to put a template message (e.g. Bug #1234:) on top of the commit message buffer ...
1
vote
0
answers
190
views
Magit ediff range in a pretty way?
I need to investigate a project, with a patch made by a former student of my university. He made a series of commits on a repo, and I need to see what additions he made.
I got the list of files ...
3
votes
1
answer
1k
views
In Magit, what is the difference between stashing "index", "worktree", or "both"?
Honestly, I have always picked both and it has worked out so far. But I do not know in which concrete cases it would be better to pick one over the other. It would be good to see examples.
I tried ...
2
votes
1
answer
254
views
How is the history.el file written? Why did this change happen?
I have been tweaking my config file (init.el). This file is inside a .emacs.d directory which is under version control by Git. I also use Magit a lot.
After editing my config, I was going to stage, ...
4
votes
1
answer
646
views
Is it possible to do a git clone using Magit in a directory which is not under version control?
Suppose I am in a folder called local-projects. Using the terminal, I can do:
[pedro@system:~/quicklisp/local-projects]$ pwd
/home/pedro/quicklisp/local-projects
An important information to ...
0
votes
1
answer
242
views
How to make `git fetch` `git rebase origin/master` work in Magit?
I have a branch that I have been working on. At the same time, master branch was evolving.
I decided to put my local branch changes on top of master new changes. Thus, after pulling changes on master, ...
2
votes
2
answers
1k
views
How to git reset --hard HEAD~1 in Magit?
I accidentally inserted 1 commit in my local master branch. I have not pushed this changed and I want to remove it. This was supposed to be in a new branch.
So, I created a new branch based on master ...
1
vote
0
answers
133
views
How to set git-gutter's default encoding
Every time I visit a buffer containing characters such as 'ç' 'á' 'ã' or 'é', emacs throws out this error:
These default coding systems were tried to encode text
in the buffer ‘ *temp file*’:
(utf-8-...