记使用 VSCode 作为 Git 编辑器在 Rebase 时没有打开 GitLens Rebase Editor 的问题

设置默认Git编辑器 core.editorcommit message 编辑时) 和 序列编辑器 sequence.editor(比如 rebase 时)

git config --global core.editor "code --wait"
git config --global sequence.editor "code --wait"

GitLens Interactive Rebase Editor

长久以来,我一直都是用的 GitLens 来操作的 Git,特别是在 rebase 的时候,可视化的界面真的比原本的文本编辑好用太多。

最近因为 Github Copilot 高级请求限制的调整,计算了一下高级请求的用量,其实改版后的 Copilot 价格和 Cursor 已经持平。所以准备迁移到 Cursor 开发一段时间(Cursor 的辅助编程体验要好太多了)。

但由于太久没有调整过 VS Code 的配置项了,在同步配置项到 Cursor 之后发现 git rebase 时,没有按照预期打开 GitLens Interactive Rebase Editor 就是上边的动图中的交互编辑器。一直都是在 Cursor 里面以文本编辑的形式打开了 git-rebase-todo 的内容。

所以记录一下如何调整和启用。

阅读全文

Git 撤销上一次提交 并将暂存区文件重新提交

把刚刚提交到的版本库的操作撤销掉,并将正确的版本提交 这时我们就需要用到 git commit –-amend 命令

我们把文件修改为正确的,然后 git add 到暂存区 再使用 git commit -–amend 命令
这时 Bash 会提示

$ git commit --amend
hint: Waiting for your editor to close the file...
阅读全文

Git 编辑历史提交的 Commit

做一个功能,可能提交了 10 多次,会不会有一些崩溃?单纯这么多次的 commit 就可能出现有无用,或者可以合并的 commit,就很让人不舒服。

基于上面所说问题,不难想到:每一次功能开发, 对多个 commit 进行合并或者删除处理,这时候就需要用到 git rebase 修改提交的历史 Commit

Eg:

修改最近的 4 次提交纪录

git rebase -i HEAD~4
  • -i--interactive 的缩写 - 交互的意思;
  • HEAD~4 修改最近的 4 次提交记录;
阅读全文

Git 遇到的一些问题

这里是我在日常中遇到的一些 Git 方面的问题。

  • Error: GH007
  • 不能退出、终止当前命令?
  • 想要删除提交的历史 Commit?
  • 合并与删除历史提交的 Commit ?
  • 操作失误,退回操作之前的版本库
阅读全文

Git 关联到GigHub

创建 SSH Keygen

使用ssh-keygen生成私钥和公钥

$ ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/yog/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/yog/.ssh/id_rsa.
Your public key has been saved in /c/Users/yog/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:0ZYdnPILyMbV9xpgRE/hWf1MayqhoEYquZTuOMr8EcE yog@YOG-DESKTOP
The key's randomart image is:
+---[RSA 3072]----+
|           =+.o.o|
|  .      .oo*=.oo|
|   E   o.o++.o++o|
|    .. .=o... .o+|
|  o.o ..S ....oo |
| = ..o   . ....  |
|o o..       .    |
|=o  .            |
|==..             |
+----[SHA256]-----+
阅读全文

Git 查看提交日志

git log

基础查看提交日志

$ git log

commit 2c8fcc81f23aa96073250e1d052473337c968d88 (HEAD -> master, origin/master)
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 12:10:01 2019 +0800

    wrote a readme file

commit 87c9d12bdd979859811fc224c7f9ade7b97b0d13
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:52:50 2019 +0800

    add distributed

commit 77ac9552a7fb2e8d1f57d324d991de11efa897f2
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:50:33 2019 +0800

    wrote a readme file
阅读全文

Git 操作命令

添加文件到仓库 git add

$ git add *

提交文件到仓库 git commit

$ git commit -m "Here is the message"

commit 命令可以提交多个之前 add 的文件

$ git add file1.txt
$ git add file2.txt file3.txt
$ git commit -m "add 3 files."
阅读全文

Git 创建版本库

创建一个空目录

$ mkdir git_demo
$ cd git_demo

创建 Git 仓库

进入目录后通过git init命令创建 Git 仓库

$ git init

Initialized empty Git repository in E:/GitLibrary/git_demo/.git/
阅读全文

安装 Git in windows


Git 官网:https://git-scm.com/

设置提交时的 NAME 和 EMAIL:

$ git config --global user.name "nikename"

$ git config --global user.email "example@example.com"

查看设置的 NAME 和 EMAIL:

$ git config user.name

$ git config user.email