基本的なgitコマンド


gitとコマンドラインで作業することができます.それを助けるために、私はいくつかの基本的なgitコマンド、それぞれが意味するもの、およびそれらを使用する方法と共に記載しました.

コマンドgit init
使用法:
空のgitリポジトリを作成するか、既存のものを再初期化します.また、プロジェクト名を指定することで、新しいディレクトリ内にレポジトリを作成します.
$ git init 

#initailize empty git repository with a name
$ git init <project-name>

コマンドgit clone
使用法:
既存のリモートリポジトリのローカルワーキングコピーを作成するために使用します.
$ git clone <remote-repository>

コマンドgit add
使用法:
gitのステージング領域にファイルを追加します.コミットが倉庫になされる前に、ファイルはGitインデックスに加えられる必要があります.
#add all files
$ git add .

#add a specific file:
$ git add <file-name>

#add an entire directory:
$ git add <directory-name>

コマンドgit rm
使用法:
作業ツリーとインデックスからファイルを削除します.
#remove a file from the working index (cached)
$ git rm --cached <file-name>

#delete a file (force)
$ git rm -f <file-name>

コマンドgit log
使用法:
コミットログを表示します.
#show entire git log
$ git log

#show git log based on commit author
$ git log --<author>="Author Name"

コマンドgit status
使用法:
作業ツリーの状態を表示します.
$ git status

コマンドgit branch
使用法:
リストを作成、削除または分岐を削除します.
#create a new branch
$ git branch <branch-name>

#list all remote or local branches
$ git branch -a

#delete a branch
$ git branch -d <branch-name>

コマンドgit checkout
使用法:
スイッチ分岐または作業ツリーファイルを復元します.
#checkout an existing branch
$ git checkout <branch-name>

#checkout and create a new branch 
$ git checkout -b <new-branch>

コマンドgit commit
使用法:
リポジトリへのレコードの変更.
#add a commit with a message
$ git commit -m "commit message in quotes"

コマンドgit merge
使用法:
一緒に2つ以上の開発履歴を結合します.
#merge changes into current branch
$ git merge <branch-name>

コマンドgit fetch
使用法:
別のリポジトリからダウンロードオブジェクトとrefs.
#fetch all of the branches from the repository
$ git fetch <remote-name>

#fetch the specified branch
$ git fetch <remote-name> <branch-name>

コマンドgit pull
使用法:
別のリポジトリまたはローカルブランチから取得し、統合します.
$ git pull <branch-name> <remote-name>

コマンドgit push
使用法:
関連付けられたオブジェクトとともにリモートリモートリファレンスを更新します.
$ git push <remote-name> <branch-name>

# push all local branches to a remote repository
$ git push —all

コマンドgit remote
使用法:
ローカルリポジトリをリモートリポジトリに接続するために使用します.
#add remote repository
$ git remote <command> <remote-name> <remote-URL>

#list named remote repositories
$ git remote -v

更なる学習
より多くのコマンドがたくさんあります.ここでは役に立つかもしれないいくつかの参照があります.
  • Basic Git Commands by Atlassian Git Tutorials
  • Git Handbook
  • Git Commands by Hostinger Tutorials
  • 読書のおかげで、私はあなたがgit完了を願っています.🎉