git用法まとめ
Gitの学习、2つのとても良い资源があって、1つは廖雪峰の公式サイトで、これは本当に分かりやすくて、もう1つはcodecademyで、深く学びたいのは歩いて行って、ここはよく使う命令だけを総括します.
1.インストール
直接公式サイトでダウンロードし、インストールしてメニューから「Git」->「Git Bash」を見つけ、コマンドラインウィンドウがポップアップされると成功します.ここではgit共通のユーザー名とメールボックスも通常設定されます.方法は次のとおりです.
2.倉庫の作成
3.ローカル変更
4.履歴照会の発行
5.ブランチとTag
6.更新とコミット
7.MergeとRebase
8.ロールバック
よくある問題と解決策
一、リモートマスターbranchがあります.名前はmasterで、AとBはmasterからローカルブランチをcheckoutし、リモートブランチを作成しました.AのローカルブランチもリモートブランチもA,BはBと呼ぶ.Aはまずコードを変更してリモートAにPushすることに成功して、それからpull requestを通じてmasterに成功して、この時BもpushコードをBに成功して、それからpull requestを創立してpushをmasterに着くのが間違いがあると思って、どのように解決しますか?
二、注釈の提出エラーはどのように後退するか
三、エラーバージョンをローカル倉庫に提出する方法
四、自分のリモートブランチバージョンの返品方法
五、共通のリモートブランチバージョンのロールバックの問題
1.インストール
直接公式サイトでダウンロードし、インストールしてメニューから「Git」->「Git Bash」を見つけ、コマンドラインウィンドウがポップアップされると成功します.ここではgit共通のユーザー名とメールボックスも通常設定されます.方法は次のとおりです.
git config --global user.name " "
git config --global user.email " email"
2.倉庫の作成
#1. clone :
git clone ssh://[email protected]/repo.git
#2. , switch , :
git init
3.ローカル変更
#1. changes
git add .
#2.
git add <file name>
#3. commit
git add -p <file name>
#4.
git commit -m "comments"
#5. changes , git add .
git commit -a
#6. changeID ,
git commit --amend
4.履歴照会の発行
#1.
git log
#2.
git log -p <file>
#3. log
git log --pretty=oneline
#4.
git blame <file>
#5. ( 、 、 )
Git reflog
,git reflog ( commit reset ), commit ,git log commit
5.ブランチとTag
#1.
git branch
#2.
git checkout <branch>
#3. +
git checkout -b <name>
#3.
git branch <new-branch>
#4.
git branch --track <new-branch> <remote>
#5.
git branch -d <branch>
#6. tag
git tag <tag-name>
6.更新とコミット
#1. ( , , )
git remote -v
git remote ( , )
#2.
git remote show
#3. , name, remote
git remote add
#4. , merge
git fetch
#4. , merge
git pull
#5.push remote
git push
#6. tags
git push --tags
7.MergeとRebase
#1.merge branch
git merge
( master ):
git checkout feature
git merge master
#2.rebase branch
git rebase
:
git checkout feature
git rebase master
( feature master , master
,rebase , , 。)
#3.
git rebase --continue
#4. rebase, rebase
git rebase --abort
8.ロールバック
#1. ,commit index .( , )
git reset --hard HEAD
#2.
git checkout HEAD
#3.revert commit ( commit )
git revert
#4.reset commit, commit
git reset --hard
#5.reset commit,
git reset --keep
よくある問題と解決策
一、リモートマスターbranchがあります.名前はmasterで、AとBはmasterからローカルブランチをcheckoutし、リモートブランチを作成しました.AのローカルブランチもリモートブランチもA,BはBと呼ぶ.Aはまずコードを変更してリモートAにPushすることに成功して、それからpull requestを通じてmasterに成功して、この時BもpushコードをBに成功して、それからpull requestを創立してpushをmasterに着くのが間違いがあると思って、どのように解決しますか?
(1) push B 。
(2)checkout -b c master check out , C
(3)git pull git pull master C
(4)git checkout B, B, git merge C, C B, , 。
(5)B git push B, pull request push master
二、注釈の提出エラーはどのように後退するか
git commit --amend
三、エラーバージョンをローカル倉庫に提出する方法
(1)git reflog commit id。
(2) id 123, git reset --hard 123 git reset --hard HEAD^
四、自分のリモートブランチバージョンの返品方法
git reflog
git reset --hard 123
git push -f ( : , , , )
五、共通のリモートブランチバージョンのロールバックの問題
: , , .
git revert HEAD
git push origin master
:
git revert 。 , , , , revert , pull , 。
git revert 。
:
reset
revert
, 。