Gitの使い方

コミットメッセージの修正

直前のコミットメッセージ以外

基本的には git rebase -i @~N を実行して 複数回(あるいは1度だけ) --amend と --continue を繰り返していく。

$ git rebase -i @~N
エディターが起動するので修正したい行の pick 部分を edit に書き換える。

Successfully と表示されるまで 下記を繰り返す。

$ git commit --amend
エディターが起動するのでメッセージを修正する。
$ git rebase --continue

直前のコミットメッセージ

$ git commit --amend

# or

$ git rebase -i @~1
$ git commit --amend
$ git commit --continue

一番最初のコミットメッセージ(first commit)

$ git rebase -i --root

# 最初のコミット行の pick を edit に書き換える。

$ git commit --amend
$ git rebase --continue

その他

IDやPASSWORDの入力を省略する

ホームディレクトリにWindows なら _netrcLinux系なら .netrc を作成する

# github
machine github.com
login ログインネーム
password パスワード

# bitbucket
machine bitbucket.org
login ログインネーム
password パスワード

passwordの取り扱いの変更について

$ git push origin main
remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.
fatal: unable to access 'https://github.com/ユーザー名/リポジトリ名.git/': The requested URL returned error: 403

とエラーが出たら https://docs.github.com/ja/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token をみること。 その後、netrcのパスワードの欄にトークンを記入する。