ID=49210 ;
commt="存取数据一致, 不让转义符生效"
git pull ;
a=`git pull|grep "up to date"|wc -l`
b=`git branch|grep \*|awk '{print $2}'`
if [ 1 == "$a" ]
then
git add .; git commit -m "RDC:$ID:$commt";
git push origin HEAD:refs/for/$b%r=指定对象,r=指定对象
=========================================================================
git 提交出现这个错误fatal: Unable to create ‘project_path/.git/index.lock’: File exists. exists
解决办法
rm -f ./.git/index.lock
=========================================================================
git恢复本地删除,修改的文件夹;
git checkout . 取消本地所有修改 取消指定文件修改或删除(恢复文件):git checkout filename
git reset --hard HEAD^ 恢复到上一个版本
1.只是修改了文件,没有任何 git 操作 git checkout -- aaa.txt
2.修改了文件,并提交到暂存区(即编辑之后,git add但没有git commit -m ....)
git reset HEAD # 回退到当前版本 (add 里面的全部撤销)
git checkout -- aaa.txt # aaa.txt为文件名
3.修改了文件,并提交到仓库区(即编辑之后,git add和git commit -m ....)
git reset HEAD^ # 回退到上一个版本 (git commit,仓库版本就会更新并记录,所以要回退的也就是上一个版本)
git checkout -- aaa.txt # aaa.txt为文件名
git restore --staged <file> : 撤销 暂存区
git restore <file> : 撤销 本地修改
git log 所有人提交过的版本信息
git relog 本地git操作记录
git log --graph --decorate --oneline --all
=========================================================================
取消增加的文件
git checkout . && git clean -df 取消本地增加的文件和所有修改
git clean -ndf 显示会删掉哪些文件
git clean -df 删除本地增加(untracked files)的文件
===============================================================
更新某个目录或文件
git fetch
git checkout -m 版本号 文件/文件夹
更新指定目录
git -C 路径 pull
==========================================================================
Your branch is ahead of 'origin/master' by 2 commits.
git reset --hard origin/master
合并多次commit为一个commit:
git rebase -i startId endID (前开后闭)
进入vi,将第一个pick改为squash 或 s(合并comitId) 删除d drop
进入comit msg页面,提交信息
git log 已经合并成功
注意:过程中有错,回退git rebase --abort
成功回退 git reflog
https://www.jianshu.com/p/964de879904a
https://www.jianshu.com/p/4a8f4af4e803
-------------------------------------------------------------------------------------
git blame path/filename 查看某一行代码是谁写的(文件各行最后一次提交记录)
git log 查看历史提交记录
git log -p filepath 查看某个文件的详细修改
git log -L start,end:filepath 查看某个文件某几行范围内的修改记录
git log -L :FunctionName:FilePath 追踪一个函数的变更历史
-------保存已修改内容,从原始态修改bug,提交后再恢复之前已保存的修改内容----------------------------
git stash 或 git stash save "别名" # save uncommitted changes
#恢复到未修改状态。进行新的修改并提交 pull, edit, etc.
git stash list # list stashed changes in this git 所有stash节点
git stash show # stat查看默认第一个存储改动的文件 git stash show stash@{num} 查看指定改动
git stash show -p # diff细节显示第一个存储的改动 git stash show stash@{num} -p 查看指定
git stash apply # 应用默认第一个存储,但不删除 指定 git stash apply stash@{$num}
git stash pop # 应用默认第一个存储,并删除 指定 git stash pop stash@{$num}
git stash drop stash@{0} -- 删除指定 git stash clear -- 删除所有缓存的stash *删除后,仍可根据Id恢复内容
git stash --help # for more info
git stash push -m "説明" path_file 指定文件緩存