LoginSignup
0
2

More than 5 years have passed since last update.

Gitでよく使うコマンドのまとめ

Last updated at Posted at 2017-12-11

git管理を始める

git init
まずはコミットが必要
git add .
git commit -m "First commit."

変更の削除

git checkout .

リモートブランチを最新にする

git fetch

リモートブランチを確認

git branch -a

ローカルとリモートの差分を表示(簡易)

git diff --name-status remotes/origin/master

ローカルとリモートの差分を表示

git diff remotes/origin/master

特定のファイルの差分を表示

git diff ブランチA..ブランチB -- 対象のファイルパス

現在checkoutしているローカルブランチにマージする。

git pull

ブランチを表示

git branch

ブランチを作成

git branch <branchname>

ブランチを削除

git branch -d <branchname>

ブランチを移動

git checkout <branchname>

commit履歴を確認

git log

ブランチ名の変更

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

今開いているブランチ名の変更

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

developにマージ

git checkout develop
git merge <branchname>

-conflictがあれば修正-

再度コミットしてマージ完了

git add .
git commit -m "fix-conflict"

リモートに新しいブランチを反映

git push origin <branchname>:<branchname>

リモートブランチにプッシュ

git push

リモートブランチの削除

git push --delete origin <branchname>

commit前の変更を退避

git stash

退避しているリストを表示

git stash list

stashの復活

git stash apply stash@{0}

最新のスタッシュを反映し削除

git stash pop

stashの削除

git stash drop stash@{N}

0
2
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
2