0
0

Gitコマンド(メモ)

Last updated at Posted at 2023-12-23

初めに

以下は、いくつかのgitコマンドのリストです。より完全なリストをお望みなら、@Pakku8914 のこちらの素晴らしい投稿をお勧めします:

Gitのセットアップ

1. mkdir git # ディレクトリを作成

2. git init # git パーソナルディレクトリを初期化

3. git --version 

4. git config --global user.name "your name"

5. git config --global user.email "your email"

6. git status

7. git add .

8. git commit -m "your message"

9. git log # コードをコミットしたユーザーの情報を表示

10. git show <commit id> # コミットに関する情報

11. git remote add origin <git repo url>

12. git push -u origin master 
# その後、GitHubのIDとパスワードを入力して特定のリポジトリにコードをプッシュする必要があります

13. git pull -u origin master 
# 最初に上記のコマンドでそのリポジトリのURLを指定する必要があります

他に知っておくべきいくつかのコマンド

1. vi .gitignore  # これにファイルを入力して、コミットから除外します

2. git add .gitignore

3. git log --grep "<search keyword>"

4. git log --oneline # コミットの数

5. git branch # ブランチのリストを表示

6. git branch <branch name>

7. git checkout <branchname> # ブランチを切り替える

8. git branch -d <branchname> # マージ前に特定のブランチを削除

9. git branch -D <branchname> # マージ後に特定のブランチを削除

10. git merge <branch name>

11. git reset <filename> # ステージングエリアからファイルを削除

12. git reset .

13. git reset --hard # ステージングエリアとワークスペースからファイルを削除

14. git clean -n or -f # ワークスペースから未追跡および不要なファイルを削除

15. git tag -a <tagname> -m <message> <commit id>

git stash

1. git stash # アイテムを隠す

2. git stash list

3. git stash apply stash@{0} # スタッシュからワークスペースにファイルを戻す

4. git stash clear 

git revertとタグコマンド

1. git revert <commit id>  # 既存のコミットを元に戻す

2. git tag -a <tagname> -m <message> <commit id> # タグを適用

3. git tag  # タグのリストを表示

4. git show <tagname>

5. git tag -d <tagname> # タグを削除

git clone

1. git clone <url of github repo>

2. git push --set-upstream origin main
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