LoginSignup
0
1

More than 3 years have passed since last update.

Git基礎的コマンドメモ

Last updated at Posted at 2020-06-08

init

gitの環境作り

git init

status

状況の確認

git status

log

ログの確認

git log

add

インデックスに登録

git add static/style.css  #ファイル指定
git add .   #全てのファイル

reset

取り消し

git reset HEAD   #addの取り消し
git reset HEAD index.html  #ファイル指定

commit

コミット

git commit -m "Message"

checkout

git checkout HEAD^   #一個前に戻る
git checkout "HEAD^"  #windowsはダブルクォーテーションで囲む
git checkout -b ブランチ名  #ブランチを作成及び切り替え
git checkout ブランチ名  #ブランチの切り替え
git checkout -f ブランチ名 #強制的にブランチを切り替える(保存していなくても)

branch

git branch  #ブランチを確認
git branch -d ブランチ名 #ブランチの削除

remote

git remote add origin URL #リモートリポジトリと紐づけ
git remote #リモートリポジトリの確認
git remote -v #リモートリポジトリのURL確認
git remote set-url origin http://zzzzz/wwww.git #URL変更

push

git push origin ブランチ名  #リモートリポジトリにプッシュする

pull

git pull origin ブランチ名  #リモートリポジトリをローカルに反映

clone

git clone "リポジトリURL"
git clone -b <指定したいブランチ名name> "リポジトリURL" #ブランチを指定してcloneする

revert

特定のcommitを打ち消す

git revert <commit>

ユーザー名とemailの設定

現在のユーザー名とemailを確認する

git config --global user.name
git config --global user.email
git config --local user.name
git config --local user.email

ユーザー名とemailを変更する

git config --global user.name "ユーザー名"
git config --global user.email メールアドレス
git config --local user.name "ユーザー名"
git config --local user.email メールアドレス
0
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
0
1