0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

時々自分が忘れてしまうGitコマンドを備忘録として残します。

push先のブランチ名省略

デフォルトの設定では以下のようにローカルブランチ名とリモートブランチ名をコマンドで打たなければなりません。

git push origin feature/name/taskName

しかし毎回打つのはめんどくさい&ミスが怖い
なので、今ローカルでいるブランチ名と同じ名前のリモートブランチにpushする方法が以下。

git config --global push.default simple
git push // ローカルがmainブランチにいれば、origin/mainにpushしてくれる

ローカルのブランチ名変更

git branch -m <変更前のブランチ名> <変更後のブランチ名>

または、今いるブランチ名を変更したい場合は<変更前のブランチ名>は不要

git branch -m <変更後のブランチ名>

リモートの向き先変更

git remote -v // 今の向き先確認
git remote set-url origin <新しい向き先>
git remote -v // 新しく設定した向き先確認

fetchとpushの向き先を別にする

git remote set-url --push origin <新しいpush先>

configを確認

git config -l // config一覧
git config <確認したい項目> // 例えばuser.name、http.proxyなど
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?