Just use it!
本地新建分支开发后,新建远端同名分支并push
git push --set-upstream origin 本地分支名
误操作恢复
git reflog找到正确hash值后git reset hash值 --hard
Reference logs(引用日志).
git log shows the current HEAD and its ancestry. That is, it prints the commit HEAD points to, then its parent, its parent, and so on. It traverses backthrough the repo’s ancestry, by recursively looking up each commit’s parent. (In practice, some commits have more than one parent. To see a more representative log, use a command like git log—oneline —graph —decorate.)
git reflog doesn’t traverse HEAD’s ancestry at all. The reflog is an ordered list of the commits that HEAD has pointed to: it’s undo history for your repo. The reflog isn’t part of the repo itself (it’s stored separately to the commits themselves) and isn’t included in pushes, fetches or clones; it’s purely local.
Aside: understanding the reflog means you can’t really lose data from your repo once it’s been committed.
rebase远程分支
git rebase -i origin/develop
本地分支重命名
git branch -m oldName newName
只想要几个功能点
git cherry-pick <HashA> <HashB>
https://ruanyifeng.com/blog/2020/04/git-cherry-pick.html
cherry-pick
https://www.atlassian.com/git/tutorials/cherry-pick
单文件版本回退
git reset Hash值 文件名.文件类型后缀
撤销本地分支与远程分支的映射关系
git branch --unset-upstream
查看本地分支与远程分支的映射关系
git branch -vv
查找指定关键字、提交人、时间后 的历史commit
git log --grep="徽标" --author="changjing" --after="2022-1-7"
修改之前提交(eg:倒数第三次
git rebase -i HEAD~3
修改 pick 为 edit ,并 :wq 保存退出
https://blog.csdn.net/sodaslay/article/details/72948722
理解git
问题
rebase目标分支之后合并仍报冲突
是由于本地存的远端库里不是最新远端代码。断掉电脑网络后git rebase origin/xxx命令仍然可以正常跑,说明此命令并不是实时拉取远端最新代码进行rebase的。因此在本地git fetch拿到远端最新变更后再变基再合并即可即可。
