git diff 比较工作区和暂存区(远端的)的不同
远端分支克隆下来到本地后的命名。
创建远程分支的本地分支(branch为远程分支的别名)并跟踪
$ git checkout -b sf origin/serverfix
Branch sf set up to track remote branch serverfix from origin.
Switched to a new branch 'sf
创建远程分支的本地分支并跟踪,此时远程分支和本地分支完全相同
$ git checkout --track origin/serverfix
Branch serverfix set up to track remote branch serverfix from origin.
Switched to a new branch 'serverfix'
创建分支后手动追踪远程分支
$ git branch -u origin/serverfix
Branch serverfix set up to track remote branch serverfix from orig
查看本地分支与远程分支追踪情况
$ git branch -vv
iss53 7e424c3 [origin/iss53: ahead 2] Add forgotten brackets
master 1ae2a45 [origin/master] Deploy index fix
* serverfix f8674d9 [teamone/server-fix-good: ahead 3, behind 1] This should do it
testing 5ea463a Try something new
查看远端最新分支号,抓取数据下来,但是不会与本地合并
$ git fetch --all; git branch -vv
合并本地端
git merge
推送自己的分支到远端
$ git push origin master
使用theirs选项从88018分支号中签出文件t1.txt的内容到工作目录以及暂存区。
git checkout --theirs 88018 -- t1.txt
将工作区回退到版本号
git reset --hard 版本号
遇到error: Your local changes to the following files would be overwritten by merge:
actions/case/apps/sg_lvgl/am82xx_drv/am82xx_evdev.c
Please, commit your changes or stash them before you can merge.
Aborting
①放弃本地工作区修改,跟本地最近一次commit同步
git reset --hard
git pull
②先存起来,抓取后对比文件不同点,也可用git stash clean 清空Git栈。
git stash
git pull
git stash pop
git log --stat
可以看出修改的文件名
git log -p -2
可以看出修改的详细记录