Questions tagged [magit]

is an Emacs extension for the Git version control system.

Magit is an Emacs menu interface to the Git version control system. Magit is implemented as an Emacs extension package -- a Git porcelain inside Emacs.

Unlike the Version Control package which is part of Emacs and strives to provide a unified interface to various version control systems, Magit only supports Git and can therefore better take advantage of its native features.

With Magit, you can inspect and modify your Git repositories with Emacs. You can review and commit the changes you have made to the tracked files, for example, and you can browse the history of past changes. There is support for cherry picking, reverting, merging, rebasing, and other common Git operations.

Magit is not a complete interface to Git; it just aims to make the most common Git operations convenient. Thus, Magit will likely not save you from learning Git itself.

699 questions
68
votes
2 answers

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 replaced by functionality in a different file. I would…
David Holm
  • 1,179
  • 1
  • 10
  • 10
67
votes
4 answers

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 look at.
Mathieu Marques
  • 1,953
  • 1
  • 13
  • 30
66
votes
2 answers

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 anywhere in the "Inspecting" section of the…
Nikratio
  • 919
  • 1
  • 6
  • 11
63
votes
4 answers

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?
caisah
  • 4,056
  • 1
  • 23
  • 43
62
votes
3 answers

What's the Magit equivalent of 'git add'?

What is the Magit equivalent of git add [--intent-to-add] for checking a newly created file into Git?
feoh
  • 900
  • 1
  • 6
  • 9
61
votes
1 answer

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?
Rafa de Castro
  • 1,231
  • 10
  • 14
57
votes
5 answers

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, Magit no longer asks you where you want to push…
Malabarba
  • 22,878
  • 6
  • 78
  • 163
51
votes
3 answers

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 not what I'm after. In magit's status buffer, I want…
Squidly
  • 1,499
  • 14
  • 17
49
votes
2 answers

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?
user2522280
  • 939
  • 2
  • 7
  • 13
45
votes
2 answers

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
wizmer
  • 877
  • 1
  • 7
  • 9
39
votes
3 answers

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 that its index state is the same as the index state…
ayvango
  • 575
  • 4
  • 6
35
votes
2 answers

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 was handy. But now in magit 2.1.0 it gives an…
Greg Hendershott
  • 1,483
  • 12
  • 17
34
votes
3 answers

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 magit by going to log, finding the commit I'm…
Emoses
  • 573
  • 5
  • 8
33
votes
3 answers

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?
deadghost
  • 807
  • 1
  • 7
  • 13
33
votes
1 answer

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, clone, commit, config, describe, diff, fetch,…
Jorge Israel Peña
  • 1,265
  • 9
  • 17
1
2 3
46 47