$git branch //查看本地分支,默認(rèn)參數(shù)-l
$git branch -a * //查看所有分支,包括遠(yuǎn)程的分支*
$git branch -r //查看遠(yuǎn)程分支
$git checkout Latte_workspace * //check遠(yuǎn)程分支到本地*
$git branch Latte_workspace_guojiaxinxi //在當(dāng)前分支上創(chuàng)建分支 Latte_workspace_guojiaxinxi
$git checkout -b Latte_workspace_guojiaxinxi * //創(chuàng)建分支并切換到新創(chuàng)建的分支*
$git push origin Latte_workspace_guojiaxinxi //推送本地分支到遠(yuǎn)程
$git branch -d Latte_workspace_guojiaxinxi //刪除本地分支
$git push origin :Latte_workspace_guojiaxinxi * //刪除遠(yuǎn)程分支*
$git commmit -m "commit massage" //提交
$git commit --amend * //修改最后一次提交*
$git cherry-pick commit哈希 * //merge某一次提交到當(dāng)前分支*
$git merge Latte_workspace * //merge Latte_workspace into current branch*
$git log * //查看提交記錄 *
$git log --oneline
$git log --graph
$git log --all
$git log --all --oneline --graph
$git reset commit 5f9ae63(哈希值 ) //切換到某一次提交狀態(tài)
必須用到的命令 fetch 及 pull,這兩個(gè)命令的區(qū)別:
- git fetch:相當(dāng)于是從遠(yuǎn)程獲取最新版本到本地,不會(huì)自動(dòng)merge
git fetch origin master:tmp
git diff tmp
git merge tmp
上述命令含義:
從遠(yuǎn)程獲取最新的版本到本地的test分支上
之后再進(jìn)行比較合并
- git pull:相當(dāng)于是從遠(yuǎn)程獲取最新版本并merge到本地
git pull origin master
上述命令其實(shí)相當(dāng)于git fetch 和 git merge
在實(shí)際使用中,git fetch更安全一些
因?yàn)樵趍erge前,我們可以查看更新情況,然后再?zèng)Q定是否合并