私のGitノート!
This is Just another post on Git. Nothing new, everything is available in web! I have just collected few important concepts for day to day work.
Git リモート サーバー
リモート リポジトリは、インターネットまたはネットワークのどこかにホストされているプロジェクトのバージョンです.
# origin - default name for remote server
git remote add origin <remote url>
# list remote urls
git remote -v
リモートブランチを追跡するには
git checkout --track origin/feature
リモートリポジトリから変更を受け取る -
git fetch
- 変更をダウンロードしてから評価できますgit pull
- フェッチとマージの組み合わせ差分を使用
diff コマンドは、git での作業中に非常に便利です.
# what changed since last commit
git diff HEAD
# diff between branches
git diff feature master
分岐が便利!
master
ブランチをチェックアウトし、コードのバグを見つけた状況を考えてみてください.それを修正するために変更を開始し、その間に、マスターを直接変更していることに気付きました!あなたは
ctrl+Z
を押すつもりでしたが、潜在的な解決策を失いたくありません.この状況では、分岐が役立ちます.新しいブランチでソリューションをチェックアウトし、ソリューションに問題がなくなるまで新しいブランチに保管してください.これは単純なシナリオですが、他にもいくつかあります.枝分かれは美しく、それを処理する方法を知っておく必要があります!# Checkout a branch
git checkout <existing branch>
# Checkout and create a new branch
git checkout -b <new branch name>
別のブランチから特定の変更 (フォルダー/ファイル) を選択する
ブランチ
features/myFix
にほとんど変更がなく、それを features/BugRel
にマージしたいとします.すべての変更はフォルダーにあります.# checkout your features/BugRel branch
git checkout features/BugRel
# pick changes from folder
git checkout features/myFix -- MyFixChanges/
それはあなたがしなければならないすべてです.そのフォルダーがブランチにあるので、コミットします.
ブランチの名前変更/削除
git branch -m <oldname> <newname>
git branch -d <branchname>
# force delete
git branch -D <branchname>
ブランチのマージと比較
Fast-forward
- ソースからの変更をマージするときに、ターゲット ブランチに競合するアクティビティがなかったため、コミットが順番に行われるgit checkout <target branch>
git merge <source branch>
マージする前に常に diff を使用する
git diff <target branch> <source branch>
マージを開始する前に、常にリモートから更新してください.
マージの中止
git merge --abort
リベース
高度な機能として、ローカル履歴をクリーンアップする (複数のコミットを 1 つにまとめる) か、マージを実行せずにブランチからブランチに変更をプルします.
your
作業ブランチのみを使用し、パブリック ブランチでは使用しないでください.git log --oneline
git rebase -i <sha>
# to visit what happened after rebase
git reflog
チェリーピック
チェリー ピッキングとは、ブランチからコミットを選択し、それを別のブランチに適用する行為です.
# find the commit details
git log <branch name> --oneline
# checkout the branch where you want to put the commit
git checkout <b-name>
# perform the cherry pick commit to HEAD
git cherry-pick <commit>
この記事は以上です.ありがとう
Reference
この問題について(私のGitノート!), 我々は、より多くの情報をここで見つけました https://dev.to/arunksingh16/my-git-notebook-32i6テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol