LoginSignup
10
8

More than 5 years have passed since last update.

-

Last updated at Posted at 2015-11-02

目立たないけど便利でニクい奴。ハイフン。

Bash

cdコマンドで指定すると、今のディレクトリにcdする前にいたディレクトリに移動できます。

[host@user ~]         $ cd ~/path/to/somewhere
[host@user somewhere] $ cd /etc/init.d
[host@user init.d]    $ cd -
[host@user somewhere] $ # ← さっきいたディレクトリに戻った!

Git

checkoutコマンドで指定すると、今のブランチをチェックアウトする前にいたブランチに移動できます。

[host@user repo] (release-1.2.0) $ git checkout add_xxx
[host@user repo] (add_xxx)       $ git checkout -
[host@user repo] (release-1.2.0) $ # ← さっきいたrelease-1.2.0ブランチに戻った!!

mergeコマンドでも、一つ前にチェックアウトしていたブランチを今のブランチにマージすることができます。
機能改修ブランチで作業していた内容をリリースブランチにマージするときなど、ブランチを行き来してマージするときに便利!

[host@user repo] (add_xxx)       $ git checkout release-1.2.0
[host@user repo] (release-1.2.0) $ git merge -
Merge made by the 'recursive' strategy. # ← さっきいたadd_xxxがマージされる
10
8
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
10
8