-----------------------------1-----------------------------
切换分支时:
/device/rockchip/rk3399# git checkout bz
error: pathspec 'bz' did not match any file(s) known to git.
因为没有这个分支,所以使用了创建并使用分支
root@adw-All-Series:/home/share/work/lhf/industry-3399-7.1/device/rockchip/rk3399# git checkout -b bz
Switched to a new branch 'bz'
-----------------------------2-----------------------------
git status //查看当前代码的修改状态
git commit -am "add pacth xxx" //提交当前修改的代码
git log //查看代码的修改日志
git log --author=xxx //查看某作者的修改日志
git show xxxxxxxxx //查看"xxxxxxxxx" 的修改
patch -p1< xxx.patch //打补丁
git diff xxx/xxx/xxx //查看与修改之前的不同
git show xxxxxxxxxx > xxx.patch //将补丁以.patch的文件格式输出查看
git checkout xxxxxxx //恢复到该补丁之后 例:xxxx该补丁的时间是2013.11.1 那么用该命令将把2013.11.1之后添加的补丁全部恢复(需谨慎)
git reset --soft xxxxxxx //恢复到该补丁之后 例:xxxx该补丁的时间是2013.11.1 那么用该命令将把2013.11.1之后添加的补丁全部恢复(需谨慎)
git commit --amend //修改commit信息
git format-patch -s xxxx //基于commit《xxx》依次打补丁
git format-patch -M master // 当前分支所有超前master的提交
git diff xxx xxxx // 将commit<xxx> 到 commit<xxxx>的修改 打印出来
git am *.patch //patch是用git format-patch来生成的,所以用git的工具应该就可以很好的做好。git am 就是作这件事情。
在使用git am之前, 你要首先git am --abort 一次,来放弃掉以前的am信息,这样才可以进行一次全新的am
git branch //查看分支
git branch name // 创建分支name
git checkout -b name // 创建+切换分支
git merge name //合并name分支到当前分支
git branch -d name //删除分支name
git branch -m oldName newName //重命名本地分支name 未提交到远程
git reset --soft xxxxxxxxxxxxx //恢复xxxxxxxxxxxxx的修改到暂存区
git checkout xxx/xxx/xx.c //恢复未缓存文件xx.c
cat .git/config //查看配置
git config core.filemode false //git中忽略文件权限的配置
git status // 查看当前代码的修改状态
git commit -am "add pacth xxx" //提交当前所有修改的代码
git log --author=xxx //查看xxx作者的修改日志
git show xxxxxxxxx //查看"xxxxxxxxx" 的修改
patch -p1< xxx.patch //打补丁
git diff xxx/xxx/xxx //查看xxx文件与修改之前的不同
git reset ---soft xxxxxxx //恢复到该commit之后,例:xxxx该补丁的时间是2013.11.1 那么用该命令将把2013.11.1之后添加的补丁全部恢复到暂存区
git reset ---hard xxxxxxx //恢复到该commit之后,例:xxxx该补丁的时间是2013.11.1 那么用该命令将把2013.11.1之后添加的补丁全部恢复(需谨慎使用)
git commit --amend // 修改commit信息
git whatchanged charge.lua // 显示某个文件的每个版本提交信息:提交日期,提交人员,版本号,提交备注(没有修改细节)
git log -p -3 ./filename 显示最近的3次提交
git log -p filename //查看文件的每一个详细的历史修改,如果没有-p选项,只显示提交记录,不显示文件内容修改
--------------------------------------------------------------
切分支时报以下错误:
error: Your local changes to the following files would be overwritten by checkout:
rockchip/rk3326/device-common.mk
Please, commit your changes or stash them before you can switch branches.
Aborting
因为这个文件rockchip/rk3326/device-common.mk 有修改,但没有提交或恢复,导致切换分支失败;恢复该文件后,切换成功
------------------------------------------------------------------
提交多行commit说明(注:使用 git commit -m " xxx 提交会自动换行 然后继续填写说明,需要结束时 补上 " 即可)
git commit -m "20201105
> 添加设置-辅助功能-状态栏开关"
----------------------------------------------------------------------
回退某个修改
git revert HEAD
//先将本地修改存储起来
git stash
//查看本地存储
git stash list
//恢复本地存储
git stash pop stash@{0}
如何解决git中文名以八进制输出的问题 ?
git config –global core.quotepath false