Skip to content

Latest commit

 

History

History
138 lines (128 loc) · 3.49 KB

magit.org

File metadata and controls

138 lines (128 loc) · 3.49 KB

MAGIT

-*- mode: org; fill-column: 78 -*-

First steps

“It’s Magit!”

Pronunciation

Why it’s great

Uniformity

  • …?

M-x “magit-status”

Put your cursor at the end of the following line and hit `C-x C-e’ (global-set-key [(control ?x) ?g] ‘magit-status)

Invoke in a subdirectory of the project to show that it finds the .git directory

What’s on the screen

Header area

Remote branch info

Local info

Head info

Untracked

Stashes

Unstaged

Staged

Unpushed

Tabbing to fold/unfold

RET to visit

Staging/Unstaging

s and u

Note the $

S-s and S-u

Unstage a staged hunk!

Commit (c)

C-c C-a to amend

C-c C-c or C-x k RET

Keeping things clean

k

Revert an unstaged change

Revert a hunk

Delete an untracked file

Stashes

Use a good description

Applying with a or A

Does not affect the index (?) Note used for cherry-picking

discard with k

Log

“ll” really fast

Navigation

SPC DEL

n, p

RET

Copy SHA as kill with C-w

Cover cherry-picking later

explain the legend later

Customizations

(customize-save-variable ‘magit-remote-ref-format ‘remote-slash-branch “Otherwise, magit uses a funky `branch-name (remote-name)’ syntax”)

(customize-save-variable ‘magit-process-popup-time 2 “If Git is taking more than a couple seconds, show me what’s happening”)

Branching/Merging

`b c’ to check out a different branch (show autocomplete)

note offer to create local tracking branch

`b B’ to create a new branch, “experiment”

add a new file

switch back to master

add a new file

merge experiment into master with m

revert

merge again with M

show the merge in the log

revert commit with x

show how changes are left as dirty files

describe X

Reflog

`h’

Show that all the usual keystrokes apply

`a’ to apply a change

Alex does a lot with `a’ and `A’ here, but the obvious thing would be to use `X’ to get back the commit you just reverted.

Remote Repositories

Set up repos foobar, foobar2 with a common remote

consider using a local remote

Stage and commit a new file in foobar

Show that it’s called out as “unpushed”

`P’ to push

f to fetch

What is the “current” remote?

F to pull

Log all

History rewriting

Three new files, three separate commits

Just amend the last commit

Then in 2 separate commits, modify the other 2 files

r s to start rewrite

apply all the commits to make it look like each file is only touched once

Note the dots and stars

Note the stacked commit messages

r f to finish the rewrite

Exercise:

create a topic branch

check in some changes

push to a remote

go back to master

rewrite topic branch history on master

someone changes remote master

rebase master on latest remote

Concepts

Viewing

commits

stashes

Staging area

Working tree state

Scenarios

Rewrite History

Rebase

Merge

Selecting changes for commit (incl hunks)

Stashing

Snapshot

Topic Branches!! (note topgit)

Log view (including log-all)

Cherry picking

bB for branch-switching

TipsTrix

V - show all branches