Git コマンド一覧



git init [repository_name]
$ git init test1
 Initialized empty Git repository in /home/ty/gits/test1/.git/
git add [file_name]
$ git add sampleFile
指定ファイルをステージングする。(バージョン管理対象に追加する) SVNの管理対象に追加するとは違い、ステージングはファイルを修正する度にしないといけない。
git commit 変更をローカルリポジトリにコミットする
 [master (root-commit) 971d175] 最初のコミットです!
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 hoge.txt
ty@xxxxx:~/gits/test1$ git status
On branch master
nothing to commit, working directory clean
 git status ローカルリポジトリと比較した変更一覧を表示する On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)modified: hoge.txt (OR modified: hoge.txt)赤字の場合、変更がステージされていない.(コミットできない)
 git log [branch_name] [branch_name]の変更履歴一覧を取得する. commit 971d175c7ce32609e02e472c88d2d8590f990359Author: Your Name <>
Date: Mon Nov 20 22:37:48 2017 +0900最初のコミットです!
 git checkout [file_name] [file_name]を元に戻す(リポジトリから復元する) -
 git show 最新の変更内容を表示する commit 81553e0982b6e8446033e89bb11bdc718044a895
Author: Your Name <>
Date: Mon Nov 20 22:45:05 2017 +0900最初の修正です!diff --git a/hoge.txt b/hoge.txt
index e69de29..f6f3236 100644
--- a/hoge.txt
+++ b/hoge.txt
@@ -0,0 +1 @@


git clone [repository_uri] リモートリポジトリからローカルリポジトリを作成する Cloning into 'xxx'...
Password for '':
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
 git push ローカルリポジトリの変更をリモートリポジトリにコミットする(書き込む)  Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 275 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
076a650..4ad7b0f master -> master
 git pull リモートリポジトリの変更をローカルリポジトリに取り込む

git コマンドでヘルプを表示

$ git

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status

grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Forward-port local commits to the updated upstream head
tag Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.


Copyright© SIerからWeb系自社開発に転職!失敗して感じたたった1つの後悔 , 2019 All Rights Reserved.