xccjk / x-blog

学习笔记
17 stars 2 forks source link

git相关 #78

Open xccjk opened 2 years ago

xccjk commented 2 years ago

git cherry-pick

https://ruanyifeng.com/blog/2020/04/git-cherry-pick.html

xccjk commented 1 year ago

git 回滚代码

场景:有时候,遇到了bugfix需要修复,但是你在修改前忘记了切换分支开发,并且提交到了develop分支,这是,你可能就需要回滚到之前的一次提交

操作步骤

-f代表强制推送,也可用--force代替

注意

很多情况下master分支会禁止强制推送,这时需要用管理员账号才可以完成

xccjk commented 1 year ago

git 删除分支

删除本地分支

git branch -D <branch_name>

删除远程分支

git push origin -D <branch_name>
// 或者
git push origin --delete <branch_name>
xccjk commented 1 year ago

git在merge代码后,未push代码之前,怎么取消merge

  1. 获取上次合并代码的id
git reflog
  1. 回滚代码
    git reset --hard id
xccjk commented 1 year ago

git查看commit提交的内容

有时候在对文件进行了commit操作后,想看一下修改的文件的具体信息,应该怎么做呢

  1. git log - 查看之前每次的commit记录列表
  2. git show - 查看最近一次已commit的文件修改信息
  3. 如果需要查看指定的某次commit的文件修改信息,git log获取那次的commit id,然后git show commitid即可查看指定的文件修改详情
xccjk commented 1 year ago

git 代理设置

设置全局代理

设置http和https

git config --global http.proxy http://127.0.0.1:8119
git config --global https.proxy https://127.0.0.1:8119

设置socks5代理

git config --global http.proxy socks5://127.0.0.1:8119
git config --global https.proxy socks5://127.0.0.1:8119

只对指定网站设置代理

设置http和https

git config --global http.https://github.com.proxy http://127.0.0.1:8119

设置socks5代理

git config --global http.https://github.com.proxy socks5://127.0.0.1:8119

取消代理

git config --global --unset http.proxy

查看全部的代理设置方式:

git config --global -l
xccjk commented 7 months ago

git 修改 commit message

修改未push的commit message休息

git commit --amend

修改刚刚push的一次提交的message信息

git log

git commit --amend

修改message信息

git pull

git status

git push

https://blog.csdn.net/Muscleape/article/details/105637401