Git

https://stackoverflow.com/a/1260982/12539782

仓库中只有一个子模块:

    git rm <path-to-submodule>
    rm .gitmodules
    rm -rf .git/modules
    git config --remove-section submodule.<path-to-submodule>

修改 commit 信息

https://stackoverflow.com/a/1186549/12539782

想修改 bbc643cd 的信息

    git rebase --interactive 'bbc643cd^'

在默认编辑器打开后,将 pick 改为 r/reword 后保存,然后就可以修改 commit 信息了。

强制从远程仓库拉取内容到本地

https://stackoverflow.com/q/70710729/12539782

    git remote -v
    # origin  git@github.com:tianheg/running_page.git (fetch)
    # origin  git@github.com:tianheg/running_page.git (push)
    # upstream        git@github.com:yihong0618/running_page.git (fetch)
    # upstream        git@github.com:yihong0618/running_page.git (push)
    git reset --hard upstream/master

Gitea

原生

选择:

  • Gitea 1.16.8
  • MariaDB 10.7.4

配置数据库

https://docs.gitea.io/en-us/database-prep/

    pacman -S mariadb

修改 =bind-address=,登录 root 用户下的数据库。

本地安装 Gitea:

1
2
3
4
5
    SET old_passwords=0;
    CREATE USER 'gitea' IDENTIFIED BY 'gitea';
    CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
    GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea';
    FLUSH PRIVILEGES;

安装 Gitea

    pacman -S gitea
    gitea # 浏览器打开 http://localhost:3000 进行配置
    sudo cp /etc/gitea/app.example.ini /etc/gitea/app.ini
    systemctl enable --now gitea

无法打开 gitea 服务。无法使用,安装失败。

refer:

  1. https://forum.hostea.org/t/howto-gitea-upgrades-a-guide-for-admins/39

Docker

https://docs.gitea.io/en-us/install-with-docker-rootless/

理解 Merge & Rebase

  1. https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
  2. https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#\_advanced\_merging
  3. https://git-scm.com/book/en/v2/Git-Branching-Rebasing

Merge 是起初两条 branches 后来合并为一条,与此同时保留被合并的分支;

Rebase 则是合并后不保留被合并的分支。

第 2 个链接中的例子还没有完全理解。

Do not rebase commits that exist outside your repository and that people may have based work on.

If you only ever rebase commits that have never left your own computer, you'll be just fine. If you rebase commits that have been pushed, but that no one else has based commits from, you'll also be fine. If you rebase commits that have already been pushed publicly, and people may have based work on those commits, then you may be in for some frustrating trouble, and the scorn of your teammates.

配置代理

对分支重命名(本地 & 远程)

How to Rename Git Local and Remote Branches

    ## Local
    git branch -m <old-name> <new-name>
    ## Remote
    # delete remote branch
    git push origin --delete <old-name> # or git push origin :<old-name>
    # push new remote branch
    git push origin <new-name>
    # To reset the upstream branch for the new-name local branch use the -u flag
    git push origin -u <new-name>

重命名远程代号(origin)

https://support.beanstalkapp.com/article/1000-how-do-i-rename-an-existing-git-remote

1
    git remote rename origin upstream

在历史中查找文件

1
2
    git log --all --full-history -- <FILE_PATH>
    git log --all --full-history -- feeds.csv

设置全局 gitignore

1
    git config --global core.excludesfile '~/.gitignore'

子模块改变地址

https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-sync–recursive–ltpathgt82308203

1
2
3
4
    # step 1
    # 手动改变 .gitmodules 中的 url
    # step 2
    git submodule sync

子模块更新

https://git-scm.com/book/en/v2/Git-Tools-Submodules

1
2
3
4
5
6
7
    # way 1
    git submodule init
    git submodule update
    # way 2
    git submodule update --init
    # way 3
    git submodule update --init --recursive # 会 clone 所有子模块(也包括子模块的子模块)

与上游仓库同步

1
2
3
4
5
6
    git checkout -b new-branch main
    git pull https://github.com/yihong0618/running_page.git upstream-branch
    # after pulling, fix the CONFLICT
    git checkout main
    git merge --no-ff new-branch
    git push origin main

使用 dura 每 5s 备份一次仓库

https://github.com/tkellogg/dura

配置

1
2
3
4
5
6
7
8
    # arch linux
    yay -S dura-git
    dura serve & # Run it in the background
    cd /git/repo/
    dura watch

    ## watch all git repo under /home/user
    find ~ -type d -name .git -prune | xargs -I= sh -c "cd =/..; dura watch" # BE CAREFUL!!! use when knowing what you are doing

不 Merge

1
2
3
4
# Since git version 1.7.4
git merge --abort
# prior git versions
git reset --merge

等待整理

Layout of comment panels