Open4
githubコマンドメモ
git clone <リポジトリ> -b <ブランチorタグ名> --depth 1
特定のブランチ or タグを指定してクローンする
--depth 1
を指定することで取得するコミットの履歴数を抑え軽量にcloneできる。
git remote show origin
リモートリポジトリ origin の詳細情報、ブランチのトラッキング情報などを表示
出力結果
* remote origin
Fetch URL: https://github.com/Monas-project/demo-cryptree.git
Push URL: https://github.com/Monas-project/demo-cryptree.git
HEAD branch: main
Remote branches:
Created-Key tracked
DID-Auth tracked
main tracked
working-1 tracked
Local branch configured for 'git pull':
working-1 merges with remote working-1
Local ref configured for 'git push':
working-1 pushes to working-1 (up to date)
git branch -vv
ローカルのブランチとそれに関連するリモートリポジトリ
新しいブランチをローカルとリモートに作成し、そこで作業を進める方法
- ローカルで新しいブランチを作成
まず、ローカルで新しいブランチを作成(この新しいブランチで作業を進めることになる)
git checkout -b 新しいブランチ名
git checkout -b add_function
- 変更をコミット:
新しいブランチで変更したものをコミット
git add .
git commit -m "update add_function"
- リモートに新しいブランチをプッシュ:
作成した新しいブランチをリモートにプッシュする。これにより、リモートリポジトリに新しいブランチが作成される。
git push origin 新しいブランチ名
git push origin add_function
- リモートでプルリクエストを作成:
GitHubで新しく作成したブランチからのプルリクエストを作成。プルリクエストのタイトルや説明を記入して、変更内容を共有。