3
1

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 5 years have passed since last update.

よく使うGit関連コマンド

Last updated at Posted at 2018-11-20

概要

備忘録

:pen_ballpoint: 備忘録

  • gitは黒い画面で操作してる想定
  • リモートリポジトリ利用してる想定

初級

git init
git add .
git commit -m '当たり前体操'

作業を始める時

git checkout -b feature/work-name origin/master

作業を終える時

git add [作業ファイル]
git commit -m 'おわたん'
git push origin feature/work-name
# そしてプルリク作成

中級

リモートのブランチリストの状況をローカルに反映させる

git fetch --prune

リモートでコンフリクトしてプルリクがマージできないと怒られたとき

git fetch
git branch -la # 対象のプルリクのブランチを確認
git merge remotes/origin/feature/conflict-something
# そして手元のエディタでコンフリクトを修正し、コミットしてプッシュ

ブランチ名変更

git branch -m <古いブランチ名> <新しいブランチ名>

# 現在いるブランチのリネーム
git branch -m <新しいブランチ名>

develop運用

masterは公開用、開発はdevelopブランチで行いたいときに使いそうなコマンド

# プッシュするとき
git push origin develop
# ※リモートのdevelopに変更があるときにはプルでマージしてから
git pull origin develop

グローバルでgitignoreしたいとき

# グローバル設定の有効化
git config --global core.excludesfile ~/.gitignore_global

# 設定を追加 .DS_Store などいれとく
vi ~/.gitignore_global
3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?