tigの使い方

こんにちは、ナナオです。 今回は私が愛用しているtigの使い方を説明していこうと思います。 tigとは tigはターミナルなどで動作する、gitのTUIツールです。 コミットやステージング、スタッシュなどの操作をTUIで実行できるのが特徴です。 同じようなTUIツールだと、最近はlazygitなどが有名ですね。 インストール インストールはbrewで行いました。 brew install tig あとは任意のgitリポジトリのディレクトリでコマンドを実行します。 tig 以下のような画面になります。 この状態でsキーを押すと、ステージングファイルなどを見ることができます。 qキーを押すことで前の画面に戻れます。 カーソルの移動はvimっぽくjkキーで行えます。 また、.tigrcというファイルをホームディレクトリに配置することで、独自のキーカスタマイズも可能です。 私はこれを利用して、リポジトリへのプッシュやgit flowを行えるようにしています。 git-flowを行えるようにする.tigrc↓ dotfiles/tigrc.git-flow at master · darcyparker/dotfiles · GitHub fetch / pull / pushを行う.tigrc↓ Tig で Git を自由自在に操作するための .tigrc 設定例 #hub - Qiita # F で fetch (default: :toggle file-name / :toggle commit-title-refs) bind generic F ?git fetch %(remote) bind main F ?git fetch %(remote) # Alt-f で :toggle file-name / :toggle commit-title-refs bind generic <Esc>f :toggle file-name bind main <Esc>f :toggle commit-title-refs # U で pull bind generic U ?git pull %(remote) # Alt-u で該当ブランチを更新 bind main <Esc>u ?sh -c "git checkout %(branch) && git pull %(remote) --ff-only && git checkout -" bind diff <Esc>u ?sh -c "git checkout %(branch) && git pull %(remote) --ff-only && git checkout -" bind refs <Esc>u ?sh -c "git checkout %(branch) && git pull %(remote) --ff-only && git checkout -" # P で remote への push bind generic P ?git push -u %(remote) %(repo:head) # S で stash save bind generic S ?git stash save "%(prompt Enter stash comment: )" # Bindings for git-flow. # # Flow bindings start with the capital F and then follow the first character of # each operation. If executed from the refs view, the operations (that make # sense to) work on the selected branch. Otherwise, they work on the currently # checked out branch. # # Commands that finish a flow require confirmation to run. Commands that create # a new flow prompt for user input and run when that input is accepted with no # confirmation prompt. # # Note: Bindings assume the standard git-flow paths of feature, release, hotfix # and support. # # To use these keybindings copy the file to your HOME directory and include it # from your ~/.tigrc file: # # $ cp contrib/git-flow.tigrc ~/.tigrc.git-flow # $ echo "source ~/.tigrc.git-flow" >> ~/.tigrc # Get rid of default bindings for F, as that will be the entry point for all # git-flow related commands with this binding. bind main F none bind generic F none # General bind generic Fi ?git flow init # Feature bind generic Ffl !git flow feature bind generic Ffs !git flow feature start "%(prompt New feature name: )" bind generic Fff ?sh -c "git flow feature finish `echo %(repo:head) | sed -e s/feature.//`" bind refs Fff ?sh -c "git flow feature finish `echo %(branch) | sed -e s/feature.//`" # Release bind generic Frl !git flow release bind generic Frs !git flow release start "%(prompt New release name: )" bind generic Frf ?sh -c "git flow release finish `echo %(repo:head) | sed -e s/release.//`" bind refs Frf ?sh -c "git flow release finish `echo %(branch) | sed -e s/release.//`" # Hot Fix bind generic Fhl !git flow hotfix bind generic Fhs !git flow hotfix start "%(prompt New hotfix name: )" bind generic Fhf ?sh -c "git flow hotfix finish `echo %(repo:head) | sed -e s/hotfix.//`" bind refs Fhf ?sh -c "git flow hotfix finish `echo %(branch) | sed -e s/hotfix.//`" # Support bind generic Fsl !git flow support bind refs Fss !git flow support start "%(prompt New support name: )" %(branch)% まとめ カスタマイズもしやすいtig、おすすめです。 ...

2026年2月10日 · にあえん

Gitに代わる新たなバージョン管理ツール「jujutsu」を使ってみる

お久しぶりです。ナナオです。 今回は今注目を集めているコードのバージョン管理ツール「jujutsu」を触ってみて、実際Gitと何が違うのか?を検証してみようと思います。 ちなみに、私は普段git-flowを使用したブランチ運用をしており、主に使用しているコマンドはこれくらいです。 init add branch commit checkout (swith) remote stash merge status インストール Windowsを使用している場合、cargoを使用してインストールします。 cargo install --locked --bin jj jj-cli --features vendored-openssl インストールできました。 > jj --help Failed to spawn pager 'LESSCHARSET=utf-8 less -FRX': program not found Jujutsu (An experimental VCS) To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/docs/tutorial.md. Usage: jj.exe [OPTIONS] [COMMAND] Commands: abandon Abandon a revision backout Apply the reverse of a revision on top of another revision branch Manage branches cat Print contents of a file in a revision checkout Create a new, empty change and edit it in the working copy [aliases: co] chmod Sets or removes the executable bit for paths in the repo commit Update the description and create a new change on top [aliases: ci] config Manage config options describe Update the change description or other metadata diff Show changes in a revision diffedit Touch up the content changes in a revision with a diff editor duplicate Create a new change with the same content as an existing one edit Edit a commit in the working copy files List files in a revision git Commands for working with the underlying Git repo init Create a new repo in the given directory interdiff Compare the changes of two commits log Show commit history merge Merge work from multiple branches move Move changes from one revision into another new Create a new, empty change and edit it in the working copy obslog Show how a change has evolved operation Commands for working with the operation log [aliases: op] rebase Move revisions to different parent(s) resolve Resolve a conflicted file with an external merge tool restore Restore paths from another revision show Show commit description and changes in a revision sparse Manage which paths from the working-copy commit are present in the working copy split Split a revision in two squash Move changes from a revision into its parent [aliases: amend] status Show high-level repo status [aliases: st] util Infrequently used commands such as for generating shell completions undo Undo an operation (shortcut for `jj op undo`) unsquash Move changes from a revision's parent into the revision [aliases: unamend] untrack Stop tracking specified paths in the working copy version Display version information workspace Commands for working with workspaces help Print this message or the help of the given subcommand(s) Options: -h, --help Print help (see a summary with '-h') -V, --version Print version Global Options: -R, --repository <REPOSITORY> Path to repository to operate on By default, Jujutsu searches for the closest .jj/ directory in an ancestor of the current working directory. --ignore-working-copy Don't snapshot the working copy, and don't update it By default, Jujutsu snapshots the working copy at the beginning of every command. The working copy is also updated at the end of the command, if the command modified the working-copy commit (`@`). If you want to avoid snapshotting the working and instead see a possibly stale working copy commit, you can use `--ignore-working-copy`. This may be useful e.g. in a command prompt, especially if you have another process that commits the working copy. Loading the repository is at a specific operation with `--at-operation` implies `--ignore-working-copy`. --at-operation <AT_OPERATION> Operation to load the repo at Operation to load the repo at. By default, Jujutsu loads the repo at the most recent operation. You can use `--at-op=<operation ID>` to see what the repo looked like at an earlier operation. For example `jj --at-op=<operation ID> st` will show you what `jj st` would have shown you when the given operation had just finished. Use `jj op log` to find the operation ID you want. Any unambiguous prefix of the operation ID is enough. When loading the repo at an earlier operation, the working copy will be ignored, as if `--ignore-working-copy` had been specified. It is possible to run mutating commands when loading the repo at an earlier operation. Doing that is equivalent to having run concurrent commands starting at the earlier operation. There's rarely a reason to do that, but it is possible. [default: @] [aliases: at-op] -v, --verbose Enable verbose logging --color <WHEN> When to colorize output (always, never, auto) --no-pager Disable the pager --config-toml <TOML> Additional configuration options jujutsuリポジトリの初期化 まずはリポジトリを作成してみましょう。 ...

2024年2月14日 · にあえん

Windows11で、cargo newで作ったgitリポジトリが「detected dubious ownership in repository」というエラーで使えない

Windows11に乗り換えたばっかりのエンジニア、ナナオです。 やはり乗り換えると今までと使い勝手が変わるので、何かするたびにエラーになりますね。 今回はGit関連でエラーが起きたので備忘録を残します。 どんなエラー? cargo newでCargoパッケージ作成すると、ありがたいことに最初からgit関連の設定もされた状態になっていると思いますが、そのパッケージ内でgitコマンドを使用するとこのようなエラーになってしまいました。 > git status fatal: detected dubious ownership in repository at 'C:/Users/Nanao/Project/study/rust-playground' 'C:/Users/Nanao/Project/study/rust-playground/.git' is owned by: 'S-1-5-32-544' but the current user is: 'S-1-5-21-2894757817-1525132421-3221859733-1001' To add an exception for this directory, call: git config --global --add safe.directory C:/Users/Nanao/Project/study/rust-playground このエラーはなんなの? 要は「このgitリポジトリの所有者はあなたじゃないから操作できませんよ」というエラーです。 結論としては以下のようなコマンドをPowerShell上で実行することで解決します。 takeown.exe /f [gitリポジトリのパス] /r | Out-Null takeownはファイルの所有者を変更するコマンドです。 Windows�Ńt�@�C���̏��L�҂��ύX�����i�R�}���h�v�����v�g�ҁj�FTech TIPS - ��IT Linuxのchownと同じようなものですね。 Linuxコマンド【 chown 】ファイルの所有者やグループを変更 - Linux入門 - Webkaru このコマンドを使用して所有者を自身に再設定しています。 まとめ いちいちこのコマンドで所有者を変更するのも面倒だなぁ…まぁ慣れればいいか…? 参考 krymtkts - git で local repo が自分のものじゃないとなったやつ

2023年10月30日 · にあえん