GithubHelp home page GithubHelp logo

sourcetreex's Introduction

SourceTree Custom Actions

This GitHub repo contains a list of useful SourceTree custom actions. Building with existing git command, it extends the SourceTree functionalities. For example, you can delete merged branches to quickly keep the remote clean; and you can undo the last commit if you made a mistake.

To use the custom actions here, simply checkout the repo on your machine. In SourceTree, open Preferences by โŒ˜ + , and then click on the "Custom Actions" tab:

From there you can "Add", "Edit" or "Remove" custom actions for SourceTree.

Type in whatever you want in the Menu Caption. It is recommended to select both the check boxes of "Open in Separate Window" and "Show Full Output" so that it is easier to capture errors if there is any.

And here are the available actions in this repo:

Remove Merged Branches

Delete all branches that are merged to current branch, master branch, dev branch or develop branch. By default, this script only deletes merged branches locally. If we want to also remove the merged branch in a remote, we can pass in the remote name as a parameter.

  • Script: remove_merged_branches.sh
  • Recommended shortcut: fn + -
  • Parameter: remote name (optional)

This is very useful for keeping the repo clean. During development, we can easily end up with a lot of PR branches that are merged. They can be clean up with this easily.

Make Zombie Branch

Rename the current branch to zombie/YYYY-MMM-DD/HH-MM-SS/{Current Branch Name}. The idea is to archive a branch instead of deleting it immediately. It is nicer to put the branches in folder start with letter "z" (zombie) instead of "a" (archive) because SourceTree will order the branches by lexical order.

  • Script: make_zombie.sh
  • Recommended shortcut: fn + A

Clean Up Zombie Branches

Zombie branches that are older than 1 month will be deleted.

  • Script: kill_zombies.sh

Safe Force Push Current Branch To Remote

You can enable force push from SourceTree directly.

However, force push is a dangerous operation since it will overwrite the history in the remote. When you make a mistake, then you'll lose your changes and there is no going back. This script will check if the remote branch has diverged from the local branch; if it is, then a zombie branch will be created in the remote so that you won't lost any of the changes.

Force push is a handy to keep the commit history clean. This feature is especially useful when being used along with git amend in SourceTree when you have some small changes that you just want to into the last commit.

By default, this script will push to origin remote. But you can specify your remote name in the parameter.

  • Script: safe_push_current_branch.sh
  • Parameter: remote name (optional)
  • Recommended shortcut: fn + F

Undo Last Commit

Sometimes we need to ad-hoc switch to a different branch. However, we cannot do that with uncommitted changes. Using this script, we can make a dummy commit to save the work-in-progress changes. And later on, after we finish the business with the other branch, we can switch back to this branch, and simply undo the last commit.

Just in case we call this script by mistake, the script will make a zombie branch before undoing the last commit.

You can call this script multiple time to undo multiple commits.

  • Script: undo_last_commit.sh
  • Recommended shortcut: fn + Z

Update Master

This allows you to update master branch from a different branch. It is very useful in combination of git rebase master. Normally, before submitting a pull request, we will update master (with this script) and rebase on the updated master branch.

  • Script: update_master.sh
  • Recommended shortcut: fn + M

sourcetreex's People

Contributors

yzhong52 avatar

Watchers

James Cloos avatar Hashim MH avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.