Skip to content

Instantly share code, notes, and snippets.

@renatorib
Last active July 22, 2019 22:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renatorib/9f1d81a64d627f1860c8ff294e54e432 to your computer and use it in GitHub Desktop.
Save renatorib/9f1d81a64d627f1860c8ff294e54e432 to your computer and use it in GitHub Desktop.
tgit

New working branch (feature, bug, etc)

tgit new fs/xyz [-b master]

git checkout master               # ensure we are on master branch  
git pull origin master --rebase   # ensure master is up to date (fetch upstream && rebase)
git checkout -b fs/xyz            # create the new src branch  
git push -u origin @              # should we auto push new src branches to remote?

I. Should we auto push new src branches to remote? Maybe a opt-in flag?

tgit sync [-b master]

git pull origin master --rebase   # ensure master is up to date (fetch upstream && rebase)

II. sync is a good name? Maybe update?

Send the working branch to stage

tgit bridge [-b stage] (entire branch)

git checkout -b fs/xyz--aux       # create a temporary 'bridge' branch to rebase from target    
git pull origin stage --rebase    # ensure stage is up to date (fetch upstream && rebase)
                                  # what should we do if user abort rebase?  
git checkout stage                # change HEAD to stage  
git pull origin stage --rebase    # since conflicts can last a long time, we do a fetch again
                                  # otherwise we can do a simply `git reset --hard @{u}`
git merge fs/xyz--aux --ff-only   # merge bridge branch with fast-forward into target branch  
git push origin @                 # should we auto push?
git checkout fs/xyz               # if we auto push, back to the working branch?

III. I do not know if bridge is a good name. Aux maybe?
IV. Should we auto push when completed? If yes, should we back to the working branch?

tgit bridge 2 [-b stage] (last 2 commits, useful when making small changes after sent working branch to stage)

COMMITS=`git rev-parse @~0..@~1`  # save the last 2 commits sha hash
                                  # (4 = @~0..@~3) (3 = @~0..@~2) (1 = @~0..@~0 or just @~0) etc.
git checkout stage                # change HEAD to stage
git pull origin stage --rebase    # fetch stage remote and merge from upstream using rebase strategy   
git cherry-pick $COMMITS          # cherry-pick the saved commits

V. Should we use the same command name?

Others...

VI. What others commands should be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment