8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

コマンドラインからSourcetreeを開きたい

Last updated at Posted at 2019-11-22

概要

ターミナルから、現在のリポジトリをサクッとSourcetreeで開きたい方向けの記事です。
普段の作業はコマンドが速いのですが、差分やログはSourcetreeが見易いので、使い分けたいところです。

環境

  • Git 2.31.1 (Apple Git-128)
  • Sourcetree 4.1.5 (241)
  • macOS Big Sur 11.5.2

何が面倒か

  • Sourcetreeで既存リポジトリをGUIでブックマーク追加するのが面倒
  • ⌘OでFinderから辿って開くのはもっと面倒

できること

  • streeを実行すると、現在いるリポジトリをSourcetreeで開けるようになります。

方法

  • Sourcetreeのメニュー -> Sourcetree -> コマンドラインツールをインストール
  • streeコマンドが入ったか確認
  • コマンドラインから以下を実行して
stree -v

現在いるリポジトリ以外も開きたい

相対・絶対パスで開けます

stree /work/target_repo/

つまり、現在のカレントディレクトリの場合は

stree .

おまけ

streeコマンドのみでシンプルに使う

デフォルトの設定ではSourcetreeで前回開いていたプロジェクトも一緒に開いてしまいます。
私はこれを無駄で紛らわしいと感じたのでオフにする方法を紹介します。
sourcetree-setting.png

  1. その他ウィンドウの復元起動時にウィンドウを復元しないを選択
  2. 起動時にブックマークを閉じたままにするにチェック

これで必要なときに必要なものだけが表示されます。

Alfredとの統一感を出す

AlfredでSourcetreeを前面にもってくるときは
「so」で呼び出すことが多いので、私はシェルに以下のエイリアスを設定しています。

alias so='stree .'

これでコマンドラインかFinder上でただ切り替えたいのかを意識せず利用できます。

おわり

GitUp、Fork、Towerなどいろいろなツールがあるので使い所を考えると良いでしょう。

最近出たGitUp、狂おしい程高性能なのでいづれGeekな使い方を紹介したいと思います。
https://gitup.co/

8
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?