ユーザ用ツール

サイト用ツール


サイドバー

git:コマンド

以前のリビジョンの文書です


よく使うコマンド

gitリポジトリを作成する

> git init

checkout

> git checkout [ブランチ名]

> git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

変更を破棄する

git checkout .

orignのURLを確認する

>git remote -v
origin  https://github.com/nekotype/native-background-timer.git (fetch)
origin  https://github.com/nekotype/native-background-timer.git (push)

>git config --get remote.origin.url
https://github.com/nekotype/native-background-timer.git

orignに手動でpushする

git push -u origin master

特定のコミットに戻す

git logでコミットidを調べて
git reset --hard [コミットid]

現在のブランチ名を確認する

> git rev-parse --abbrev-ref HEAD

ブランチを切り替える

> git checkout master

ブランチを作る

//ブランチを作る
git branch [new branch]

//コミットからブランチを作る
git branch [new branch] [commmit]

//ブランチを作って切り替える
git checkout -b [new branch]

コミットメッセージを修正する

git commit --amend -m "変更後のメッセージ"

インデックスに追加

git add .         //すべてのファイル・ディレクトリ
git add *.css     //すべてのCSSファイル
git add -n        //追加されるファイルを調べる
git add -u        //変更されたファイルを追加する
git rm --cached   //addしてしまったファイルを除外

追加の取消し

// git init 後、初回コミットまで
git rm --cached -r .      // 全てのファイルを取り消し
git rm --cached -r file_name   // 特定のファイルを取り消し

// 初回コミット以降   
git reset HEAD                  // 全てのファイルを取り消し
git reset HEAD file_name        // 特定のファイルを取り消し
git/コマンド.1568154301.txt.gz · 最終更新: 2019/09/11 07:25 by ips