Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [magit]

is an Emacs extension for the Git version control system.

44
votes
1answer
4k 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?
40
votes
4answers
9k 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, ...
36
votes
2answers
6k 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 ...
33
votes
3answers
8k 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?
32
votes
3answers
5k 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?
32
votes
4answers
7k 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 ...
32
votes
2answers
4k 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 ...
25
votes
3answers
2k 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 ...
24
votes
2answers
7k 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?
22
votes
2answers
3k 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
21
votes
3answers
9k 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?
19
votes
1answer
2k 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 ...
19
votes
2answers
4k 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 ...
19
votes
1answer
1k 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, ...
18
votes
1answer
2k 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 ...
17
votes
2answers
702 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 ...
16
votes
1answer
2k 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, ...
16
votes
3answers
4k 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 ...
15
votes
2answers
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
3answers
501 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
1answer
1k 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 ...
15
votes
1answer
391 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 ...
14
votes
2answers
2k 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 ...
14
votes
2answers
862 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 ...
14
votes
2answers
2k 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 ...
13
votes
2answers
4k 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? ...
13
votes
4answers
988 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?
13
votes
1answer
871 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(...
13
votes
2answers
2k 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 ...
13
votes
2answers
1k 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 ...
13
votes
2answers
300 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 ...
12
votes
2answers
2k 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 ...
12
votes
1answer
702 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?
12
votes
2answers
719 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 ...
12
votes
2answers
3k views

Magit extremely slow in Windows. How do I optimize?

I am forced to used Windows 10 for a project. Yes, I would rather use GNU/Linux. To keep my sanity, I've tried to view Windows as a bootloader for emacs :) Unfortunately, Magit (one of my favorite ...
11
votes
2answers
2k 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 ...
11
votes
2answers
370 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 ...
10
votes
8answers
947 views

magit-push hangs on Windows

I'm using GNU Emacs on Windows, and I am unable to use magit-push to push my local changes to a remote repository. This happens with remote repositories regardless of if they are accessed with SSH or ...
10
votes
7answers
1k views

How to Implement Popup Menu Similar to That Used in Magit

Question I would like to create user interface in form of popup menu, popup menu similar to that used in Magit. Features Definition of Popup Popup in context of this question means little ...
10
votes
3answers
150 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 ...
10
votes
2answers
1k 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-...
10
votes
2answers
1k 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 ...
10
votes
1answer
351 views

How to well deal with the git diff with compatible to visual-line-mode?

I typeset my manuscript in org-mode with visual-line-mode turned on. Physically one of my paragraphs is just a line which is soft-wrapped. In this case, when I tried to git diff (magit) to see what I ...
10
votes
3answers
1k views

How to prevent Magit from asking where to push a branch?

When calling magit-push-current with P P from the status buffer, Magit 2.1.0 asks me where to push the branch on the first time, when upstream is not set. How can it let automatically generate the ...
9
votes
2answers
3k 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 ...
9
votes
1answer
4k views

How do I set the upstream branch to push a local branch to in magit?

From what I remember, if I am working on a branch, e.g., my-feature-branch, I used to be able to do this from the magit-status menu with P P, and then selecting the remote branch from a list which had ...
8
votes
2answers
625 views

Default Magit commit state in Evil

I use evil. Normally, when I commit, I'd like to immediately start typing, but evil starts the buffer in evil-normal-state. I used to set (evil-set-initial-state #'git-commit-mode 'insert) But that ...
8
votes
1answer
256 views

Change the default visibility of a Magit section

I have a fork of popular repo, I want to be able to keep track of commits being push to that repo while also having my own personal commits to my fork. I don't really want my changes to be merged ...
8
votes
3answers
273 views

How to scroll up when expanding a section in magit-status?

In the magit-status buffer, pressing TAB shows or hides a given section, which is handy when looking at unstaged content and see what hunks can be staged. However, when tabbing on a section, the ...
7
votes
3answers
2k views

Get git repo root directory, preferably with magit

How can I get the root directory of the current git repo? I could run shell-command-to-string on something like git rev-parse --show-toplevel. Is there a better way? Does magit or any other git front-...