Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Email Driven Git Workflow

Email Driven Git Workflow

1. Send your works to peers:

(@ wanted branch)

$ git format-patch -o patched/ -1

  • how many commit? 1

$ git log --format=oneline --decorate=short -10 patches/git.log

  • how many commit? 10 (more than patches.)

Send email to peer with these:

  • Commit or Feature Name:
  • Summary of commits:
  • Which branch are you working on? eg. master
  • Add attachments: patches/*.patch
  • Add attachments: patches/git.log

(You can also verify your patch before sending it! - GOTO: V.)

2. Receive peer's works:

(@ wanted branch)

$ git am patches/

  • When failed: $ git am --abort

and Check and compare: $ git log

If COMMIT was differ:

  • $ git reset --hard origin/master
  • $ cp .hooks/post-applypatch .git/hooks/post-applypatch (link)
  • Retry.
    • Failed? Ask to send bundle file! (- GOTO: B.)

V. Verify!

Create baseline for peer:

  • $ cd ..
  • $ git clone {GIT_URL} {PROJECT_NAME}.for_peer

Match git log history with peer:

(@ wanted branch)

  • $ git reset --hard HEAD^1
  • $ git log and compare it. (until matched, anyway.)

Verify git am

  • $ git am patches/
  • $ git log

If error occured, check the error message or check below section for limitations (GOTO: X.)


U. Unexpected Commit ID. What's wrong?


X. Current Limitations for git format-patch and git am.

git format-patch doesn't cover:

  • Merged commits
    • git pull
    • git merge --no-ff
  • Empty commits
    • git commit --allow-empty
  • Changed commits
    • git commit --amend (author time differ with committer time)

git am eats:

  • Commit message starts with [] bracket. (eg. [ACTION REQUIRED])

When we met limitations: Bundle it!


B. Bundle Method:

B-1. PREPARE: Create baseline for peer.

  • $ cd ..
  • $ git clone {GIT_URL} {PROJECT_NAME}.for_peer

(Match git log history with peer:)

  • $ cd {PROJECT_NAME}.for_peer
  • $ git checkout master (or wanted branch.)
  • $ git reset --hard HEAD^1 (until matched, anyway.)

(but add this to original workspace as new remote.)

  • $ cd ..\{PROEJECT_NAME}
  • $ git remote add for_peer ..\{PROJECT_NAME}.for_peer

B-2. Bundle!

(replace master to wanted branch.)

  • $ git fetch for_peer master

  • $ git fetch origin master

  • $ git bundle create master.bundle for_peer/master..origin/master

    • or $ git bundle create master.bundle origin/master..master
  • $ git bundle verify master.bundle

  • $ git log --format=oneline --decorate=short -10 > master.log

B-3. Verify before sending.

(replace master to wanted branch.)

  • $ cd ..\{PROJECT_NAME}.for_peer
  • $ git bundle verify master.bundle
  • $ git fetch master.bundle master:unbundled
  • $ git log unbundled
  • $ git branch -d unbundled

B-4. Unbundle!

(replace master to wanted branch.)

  • $ git bundle verify master.bundle
  • $ git fetch master.bundle master:unbundled
  • $ git checkout unbundle
  • $ git log compare
  • $ git checkout master
  • $ git merge unbundled
  • $ git log compare
  • $ git branch -d unbundle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.