origin
为远程仓库名, branch
在 origin/branch
中指该远程仓库中分支名, 其他地方表git命令选项
回退某个文件的版本 file.txt
git log file.txt # 共4个步骤
记下需回退的版本号 commit_id
git rest commit_id file.txt
git commit -m 'commit message'
建立跟踪分支
1. 需要自定义本地仓库名称:(name为本地仓库的名称, origin/branch为远程仓库名/分支名)
git checkout -b <name> origin/branch
2. 通远程仓库名相同
git checkout --track origin/branch
删除本地分支
git branch -d branch_name
如果本地分支没有合并到主分支,需要使用 -D 选项, 即
git branch -D branch_name
删除远程分支
git push --delete origin/branch # 3种方法
git push origin --delete branch
git push origin :branch
比较两个分支的不同
git log branch1_name --not branch2_name
推送本地分支(非跟踪分支)到远程已有分支
git push origin local_branch:remote_branch