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?

GitHub上にあるプロジェクトから始メル際に使用するGitコマンド集

Posted at

よく使うGitコマンドを以下にまとめてみた。

リモートリポジトリのコピーを作成する

git clone <リポジトリURL>
  • ローカルリポジトリの作成
  • ワーキングツリー(ファイル群)のコピー
  • originという名前でリモートの設定も登録される
    ※別の名前にしたい場合は、git remote add <別名> <リポジトリURL>を実行

変更をステージに追加する

git add <ファイル名>
git add <ディレクトリ名>
git add .

コミット

git commit -m "メッセージ"

変更状況確認

git status

変更履歴確認

git log

リモートにpush

git push <リモート名> <ブランチ名>
git push origin master

管理しないファイルについて

.gitignoreファイルにファイル名を追記する

ファイルへの変更を取り消す

ステージング前

git checkout -- <ファイル名>
git checkout -- <ディレクトリ名>
git checkout -- .

ステージング後

git reset HEAD <ファイル名>
git reset HEAD <ディレクトリ名>
git reset HEAD .

コミットやり直し

git commit --amend

最新取得

git pull origin master ## 現在のローカルブランチにリモート(origin)の最新のmasterブランチを取り込む

ブランチ作成&切り替え

git checkout -b <新ブランチ名>

マージ

git merge <リモート名/ブランチ名>
git merge origin/master ## 現在の作業ブランチにマージする

修正内容を退避する

git stash

git stash list ## 退避した作業の一覧を取得

git stash apply ## 最新の退避を復元する
git stash apply <スタッシュ名>

git stash drop ## 退避を削除する
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?