checkout remote branch

git fetch origin && git checkout --track origin/branch_name

检查某个key被哪个repo使用

ssh -T -ai ~/.ssh/id_rsa [[email protected]](mailto:git@github.com)

会打印出id_ras是否被某个repo作为deploy key.

生成patch

git diff > 1.patch
git diff branch_name
git diff --staged path/to/file
git diff commit_id1 commit_id2

打补丁

git apply patch_file.patch 

git diff vs git format-patch

The patch file can be generated with the git diff command, but comparing with the patch generated by the git format-patch command, the major differences are:

  1. No metadata about a commit (such as date, author, commit message, etc.) ;
  2. No statistics about the diff (diffstat, such as x files changed, y insertions(+), z deletions(-));
  3. No binary diffs, only textual diffs.

如果是弄脏了branch重新交PR,rebase以后谨慎用format-patch,尤其是master branch已经更新了的情况下。

git fetch

如果是--depth 1 clone的repo, git fetch --depth 1 origin remote_branch:local_branch

让git自动用某个key

export GIT_SSH_COMMAND='ssh -i ~/.ssh/your_private_key'

Reference

https://stackoverflow.com/questions/1783405/how-do-i-check-out-a-remote-git-branch

https://docs.github.com/en/authentication/troubleshooting-ssh/error-key-already-in-use

https://stackoverflow.com/questions/4624127/what-is-the-difference-between-git-format-patch-and-git-diff


文章版权归 FindHao 所有丨本站默认采用CC-BY-NC-SA 4.0协议进行授权|
转载必须包含本声明,并以超链接形式注明作者 FindHao 和本文原始地址:
https://findhao.net/easycoding/2606.html

Comments