Questions tagged [magit]
is an Emacs extension for the Git version control system.
704
questions
69
votes
2
answers
13k
views
How can I open a specific revision of a file with Magit?
Is it possible to open a specific revision of a file in Emacs with Magit without changing the current branch?
I have rebased some local changes to a revision where the modified functions were ...
67
votes
4
answers
17k
views
Add change to a previous commit with Magit
I have 2 commits, A then B, ready to be pushed. I realize I forgot to add something in A.
How can I add this change to A using Magit? I don't even know which part of the Git documentation I should ...
66
votes
2
answers
12k
views
How to list branches with Magit
How do I list the branches of a repository in Magit (i.e., the equivalent of git branch --list)? I expected to find this in the branch popup, but it seems to be neither there nor was I able to find it ...
63
votes
4
answers
17k
views
How to easily cherry pick with magit?
I've been using magit for a few months now and I like it a lot. But one thing I still do it in a terminal is cherry picking.
What is a simple way to do this?
63
votes
3
answers
22k
views
What's the Magit equivalent of 'git add'?
What is the Magit equivalent of git add [--intent-to-add] <filename> for checking a newly created file into Git?
61
votes
1
answer
8k
views
Can I checkout a given commit from magit's log view?
I'm exploring a git repository history using magit's log view using l l. Can I checkout a given commit from there without going to terminal?
57
votes
5
answers
16k
views
Change a branch's upstream with Magit
When you push a branch with Magit (with P P) and the branch has no
upstream, Magit asks you the name of the branch you want to push to.
That's great.
Once you set the upstream for a branch, however, ...
51
votes
3
answers
9k
views
Magit split hunk into two hunks
There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's ...
48
votes
2
answers
18k
views
How can I discard changes to unstaged files using magit?
Is there a way to issue the command:
git checkout NameOfFile
on a modified and unstaged file from within MAGIT?
46
votes
2
answers
11k
views
Git rm from magit
This is a very basic but I have been unable to find the answer on the web.
Is it possible to git rm, i.e. to remove a tracked file, from magit?
Thanks
40
votes
3
answers
6k
views
How to stash individual files with magit
git is capable of stashing of individual hunks.
With --patch, you can interactively select hunks from the diff between HEAD and the working tree to be stashed. The stash entry is constructed such ...
35
votes
3
answers
9k
views
How do I checkout a file from another commit in Magit
I've got a file foo.txt in branch A, and I want to check out foo.txt from branch B into the index. On the command line, I would do this:
$ git checkout B -- foo.txt
I want to be able to do this in ...
35
votes
2
answers
9k
views
Reverse a hunk in Magit 2.1.0
I just upgraded to magit 2.1.0. (And also to emacs 25.0.50 and git 2.3.1.)
Previously, in the *magit* buffer I could:
Select a hunk in the Unstaged area.
Type v and answer yes to reverse it.
This ...
33
votes
3
answers
12k
views
Untrack file without deleting it?
I have a tracked file in a git repository. How do I untrack this file without deleting it using magit?
33
votes
1
answer
5k
views
how to move/rename a file within Magit?
The manual's introduction says:
Magit wraps and in many cases improves upon at least the following Git porcelain commands: add, am, bisect, blame, branch, checkout, cherry, cherry-pick, clean, ...
31
votes
3
answers
10k
views
Magit, how to use system's ssh agent and don't ask for password
I've googled and read the FAQ and Wiki for Magit, but still unable to figure this out, all I find are answers about Windows...
How can I configure Magit to use my running ssh-agent session and don't ...
30
votes
1
answer
3k
views
In Magit, what is the difference between a 'stash' and a 'snapshot'?
The Magit user manual includes two sets of "stashing" commands: lower-case commands save a stash, and upper-case commands save a snapshot. After consulting Google and Stack Overflow and the git-stash(...
29
votes
1
answer
4k
views
Choose files to stage of a new directory with magit
If you create a new directory, its files won't show up with magit-status, only the new directory is in the list of Untracked items.
Currently I have to magit-stage-item the new directory and then ...
27
votes
2
answers
5k
views
How can I list available tags in Magit?
I would like to list the available tags in Magit in order to diff a specific revision, is this possible?
Specifically what I am after is to list the revision history at a certain tag and then view ...
27
votes
2
answers
3k
views
Magit log dates
In Magit log buffer commits (one per line) are shown with relative date. This is nice for recent commits, but makes little sense for older changes. In particular, this makes it annoyingly hard to ...
27
votes
1
answer
2k
views
Magit equivalent for "git remote -v" (list remotes)
I'm wondering if there is a magit equivalent to git remote -v to list remotes and their URL's defined on a git repository. The magit remotes popup offers options to add, remove, rename, and set url, ...
25
votes
4
answers
4k
views
Magit - How to expand all and collapse all sections in magit-status
Pressing TAB on a single unstaged file shows or hides details pertaining to that file.
How do I show & hide (toggle) details of all unstaged files at once?
I did come across outline-hide-...
25
votes
2
answers
11k
views
Magit - How can I checkout a remote branch locally without typing the entire branch name?
I have a remote branch remote-branch-long-name. When I magit checkout with helm completion I can type remote-branch and origin/remote-branch-long-name will show up as an option. The issue is that to ...
23
votes
2
answers
7k
views
How to automatically sign commits with magit?
I'm interested on having each of my commits signed with my GPG key. Since I use magit for interfacing with git, I was wondering if telling magit to sign each commit was possible (or some workaround to ...
23
votes
2
answers
4k
views
How to checkout ours/theirs on a file in magit?
Let's say I have a merge conflict. I see a conflicted file like this:
Unstaged changes:
Unmerged Foo/bar/wibble/plop/elbow.txt
I can hit tab here to open the changes and maybe jump to a point ...
22
votes
3
answers
10k
views
Using magit for the most basic add, commit, push
I normally use only a few git commands each time I want to commit changes to a repository:
$ git add --all .
$ git commit -m "update."
$ git push -u origin master
Can magit be useful in this regard? ...
22
votes
1
answer
3k
views
magit blame: is there an equivalent for "show me the file before this commit" from VC?
VC blame mode has a nifty a hotkey "show me blame of the file before the commit I'm pointing at".
Is there an equivalent in magit?
22
votes
2
answers
9k
views
Magit diff side by side
I would like to know if there is a way to get the standard side by side diff view in magit. That is, instead of seeing the old code chunk and the new one one after the other, I'd like to see them on ...
21
votes
5
answers
3k
views
Magit: How to show differences within lines
I have a file, I make some changes.
Here how SmartGit shows differences.
As you can see it shows where the difference is within the line. It changes background to red color in concrete position. And ...
21
votes
2
answers
2k
views
How to pronounce "magit"?
Q: How does one pronounce magit?
It occurred to me today that I've never said "magit" out loud, and I'd prefer not to make a fool of myself if I ever have to do so.
So: is the g in magit pronounced ...
20
votes
1
answer
13k
views
Magit - Undo last commit - History Manipulation
This StackOverflow question has the best solutions/approaches to undo last commits.
I started using Magit a couple a weeks ago and after looking through all its documentation I still don't have a ...
18
votes
5
answers
2k
views
How can I make `--verbose` flag be enabled by default in magit commit screen?
Right now, instead of pressing just cc in magit-mode, I have to press c-vc every time to enable --verbose.
Is it possible to make it enabled by default?
18
votes
3
answers
2k
views
Manage several git repositories from magit
I'm maintaining several git repositories using magit, and their
numbers keep growing. Is there a way to inform magit of
all these projects so that a single command would present a summary of
the ...
18
votes
3
answers
7k
views
Magit extremely slow in Windows. How do I optimize?
I am forced to use Windows 10 for a project. Yes, I would rather use GNU/Linux. To keep my sanity, I've tried to regard Windows as a bootloader for Emacs :)
Unfortunately, Magit (one of my favorite ...
17
votes
1
answer
2k
views
How to access command switches in Magit
Most magit commands are invoked with a single key, which pops up a menu of
subcommands and switches. For example, P shows P and t as subcommands and -f and -u as "switches."
Hitting the letters for ...
17
votes
1
answer
719
views
Combining magit with undo-tree for easy history navigation
I love undo-tree (screenshot below). It provides an easy way for navigating through different versions of a file (top window) by letting the user move around the file's history tree in a separate ...
16
votes
2
answers
2k
views
Git: is it possible to stage a selected region directly from the file buffer?
With Magit you can open the magit status buffer, press TAB to expand the diff (or RET to bring up a separate diff buffer), mark parts of a hunk and press s or u to stage/unstage the region. Really ...
15
votes
2
answers
1k
views
Can Magit do git format-patch?
I just wanted to know if Magit has this functionality. The reference manual does not have this explicitly so that's why I am asking.
15
votes
3
answers
838
views
Command to visit Github pull request of current branch with Magit
It's very common that, after pushing a given branch upstream, I'll want to visit it on github and create a pull request. I'm starting to get annoyed at having to manually visit the repo, find the ...
15
votes
2
answers
611
views
Magit pushing / pulling show progress
I'm missing some visual indication of the push / pull progress. After executing the appropriate command, magit prints
Pushing to domain.tld:repo.git
however, no further indication of the ...
14
votes
1
answer
5k
views
Simple rebase from master with magit?
I just upgraded to the newest version of Magit having used the old version for years. All the improvements are great after a little searching around and figuring out the differences.
Now, I'm just ...
14
votes
2
answers
2k
views
Is it possible to limit magit's log view to just commits from the current branch?
Currently when I bring up the local magit log ("l l") it takes a fair amount of time. It would be nice for the log just to limit itself to the nearest merge base (e.g. vs origin/master) but I haven't ...
14
votes
2
answers
11k
views
Use magit to display the difference between two branches
Is there a way to bring up a big list of the differences between specific commits across two branches?
I tried the method described in this answer but it came back empty, I assume because the ...
13
votes
2
answers
3k
views
How do I force a specific buffer to open in a new window?
When committing changes in Magit, it is useful to have the diff view open while adding details about the commit.
In Magit, we see the diff in the *magit ..* buffer. When you hit cc while the cursor ...
13
votes
2
answers
857
views
Magit: don't ask to save changes
When I have a buffer with unsaved changes, magit asks for each and every action to save that changes.
I didn't save that changes on purpose, so is there a way to disable this behaviour? My Magit ...
13
votes
1
answer
5k
views
How to checkout a specific commit inside magit?
Inside the magit log history, I can see the list of commits. How do I roll back to a specific commit from the list?
I can move to that commit and use d to see the diff/change of that commit, but I do ...
12
votes
3
answers
1k
views
Magit: Copy text from Stage section without character "+"
Windows 10, Emacs 25.1, Magit
I select some text (Shift + Arrow Down) from the Unstaged changes section.
Here is a screenshot:
Then I paste into another buffer (*scratch*).
This is the result:
Is ...
12
votes
4
answers
3k
views
Magit Status - always split vertically
Is there a configuration option in Magit that will force the "git status" window to always appear in a vertical split? I didn't see anything about that in the documentation, and Google was rather ...
12
votes
2
answers
2k
views
Magit + gerrit - push to other branch
I am using gerrit. When I want to push my commits, I use following command:
git push origin HEAD:refs/for/master
How can I recreate the same command using Magit?
11
votes
3
answers
1k
views
A way to insert a predefined text into Magit's commit message window?
We have a convention that every commit message begins with an issue number.
I'd like to be able to programmatically insert the issue number part (computed by a separate function) into the commit ...