Skip to content

Instantly share code, notes, and snippets.

@ninokierulf
Last active June 19, 2020 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninokierulf/dce254ead1d3b61f3c71179c0f0a46ab to your computer and use it in GitHub Desktop.
Save ninokierulf/dce254ead1d3b61f3c71179c0f0a46ab to your computer and use it in GitHub Desktop.
gitworkflow: Topic Dependency has new code (rebase --onto)

gitworkflow

Scenario

  • Topic-B depends on Topic-A
  • Topic-A has updates
  • Topic-B want Topic-A updates by replacing old merge to have clean graph
(topic-b)$ git tag "outdated"
(topic-b)$ git reset --hard master #if master is parent of Topic-B
(topic-b)$ git merge --no-ff topic-a
(topic-b)$ git tag "updated"
(topic-b)$ git reset --hard outdated
(topic-b)$ git rebase --onto updated {old_topic_A_merge_sha1}

Remove Helper Tags

(topic-b)$ git tag -d updated
(topic-b)$ git tag -d outdated

Git alias

open .git/config

[alias]
  # Pull updates from topic dependency
  # usage: git topicpull {topic} {sha1 merge in topic} {master}
  topicpull = "!f() { git tag \"outdated\"; git reset --hard ${3:-master}; git merge --no-ff $1; git tag \"updated\"; git reset --hard outdated; git rebase --onto updated $2; git tag -d updated; };f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment