From 789ca27deb3b8f4d22757105a0c38c0aee5dac0e Mon Sep 17 00:00:00 2001 From: az-P1-openSUSE Date: Fri, 11 Aug 2023 18:32:39 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notes-OS/cross-platform/git.md | 142 +++++++++++++++++- .../{hard_disk.md => hard-disk.md} | 0 notes-OS/cross-platform/index.md | 10 +- notes-development/Docker.md | 2 +- notes-development/Java.md | 5 + notes-development/git.md | 127 ---------------- notes-development/index.md | 6 +- notes-development/tips.md | 4 +- 8 files changed, 152 insertions(+), 144 deletions(-) rename notes-OS/cross-platform/{hard_disk.md => hard-disk.md} (100%) create mode 100644 notes-development/Java.md delete mode 100644 notes-development/git.md diff --git a/notes-OS/cross-platform/git.md b/notes-OS/cross-platform/git.md index 1172415..5cf5b2e 100644 --- a/notes-OS/cross-platform/git.md +++ b/notes-OS/cross-platform/git.md @@ -1,6 +1,4 @@ -# Git Configuration - -This note contains configuration related tips. See [[notes-development/git]] for other git operation tips. +# Git Usage Tips - [Local configuration](#local-configuration) - [Show configs](#show-configs) @@ -9,11 +7,23 @@ This note contains configuration related tips. See [[notes-development/git]] for - [Specify how to reconcile divergent branches](#specify-how-to-reconcile-divergent-branches) - [GitHub configuration](#github-configuration) - [Add SSH key to GitHub](#add-ssh-key-to-github) +- [Commit message convention](#commit-message-convention) +- [Change commit messages](#change-commit-messages) +- [Clone to a specific directory](#clone-to-a-specific-directory) +- [Embedded repo](#embedded-repo) +- [Update an unchecked-out local branch from remote branch](#update-an-unchecked-out-local-branch-from-remote-branch) +- [Discard unstaged changes](#discard-unstaged-changes) +- [Stash changes](#stash-changes) +- [Rename branch](#rename-branch) +- [Change remote origin](#change-remote-origin) +- [Hard reset remote branch](#hard-reset-remote-branch) +- [Private fork](#private-fork) - [墙国专属](#墙国专属) - [Change `hosts`](#change-hosts) - [Set proxy](#set-proxy) - [Linux](#linux) - [Other methods](#other-methods) +- [Interesting posts](#interesting-posts) ## Local configuration @@ -36,7 +46,7 @@ Use `git config --global core.autocrlf false` or edit the `gitconfig` file direc ### Specify how to reconcile divergent branches -Use `git config --global pull.rebase false` to suppress this warning: +Use `git config --global pull.rebase false` to suppress the following warning: ```log hint: You have divergent branches and need to specify how to reconcile them. @@ -64,7 +74,119 @@ fatal: Need to specify how to reconcile divergent branches. ### Add SSH key to GitHub 1. Generate a key. See [[SSH#Generate SSH key]]. -2. Refer to [the GitHub guide](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account). +2. See [the GitHub guide](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account). + +## Commit message convention + +*References*: + +- [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) + +## Change commit messages + +- Change the last one: `git commit --amend` +- [ ] Change multiple + +*References*: + +- [Changing a commit message](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/changing-a-commit-message) + +## Clone to a specific directory + +Use `git clone git@github.com:SOME_REPO TARGET_DIRECTORY`. + +*References*: + +- [How do I clone a Git repository into a specific folder?](https://stackoverflow.com/questions/651038/how-do-i-clone-a-git-repository-into-a-specific-folder) + +## Embedded repo + +*References*: + +- [Git: How to make outer repository and embedded repository work as common/standalone repository?](https://stackoverflow.com/questions/47008290/git-how-to-make-outer-repository-and-embedded-repository-work-as-common-standal) + +## Update an unchecked-out local branch from remote branch + +Use `git fetch REMOTE_REPO REMOTE_BRANCH:LOCAL_BRANCH`. + +*References*: + +- [How to 'git pull' into a branch that is not the current one?](https://stackoverflow.com/questions/18994609/how-to-git-pull-into-a-branch-that-is-not-the-current-one) + +## Discard unstaged changes + +- Discard all: `git restore .` +- Discard a specific file: `git restore PATH_TO_THE_FILE` + +*References*: + +- [How To Completely Reset a Git Repository (Including Untracked Files)](https://www.howtogeek.com/devops/how-to-completely-reset-a-git-repository-including-untracked-files/) + +## Stash changes + +- Stash changes by `git stash`. +- Pop stash by `git stash pop`. + +*References*: + +- [Git stash](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) + +## Rename branch + +- Rename checked-out local branch: Use `git branch --move NEW_BRANCH_NAME`. +- Rename unchecked-out local branch: Use `git branch --move BRANCH_NAME NEW_BRANCH_NAME`. + +## Change remote origin + +Use `git remote set-url REMOTE_NAME NEW_URL`. + +*References*: + +- [How To Change Git Remote Origin](https://devconnected.com/how-to-change-git-remote-origin/) + +## Hard reset remote branch + +After hard resetting the local repo, use `git push -f REMOTE_REPO BRANCH_NAME` to hard reset the remote repo. + +## Private fork + +1. Create a new repo (`PRI_REPO`) via the GitHub Website. +2. Duplicate the public repo (`PUB_REPO`) via the following commands: + + ```bash + git clone --bare https://github.com/exampleuser/PUB_REPO.git + cd PUB_REPO.git + git push --mirror https://github.com/yourname/PRI_REPO.git + cd .. + rm -rf PUB_REPO.git + ``` + +3. Clone the private repo and add `upstream` via the following commands: + + ```bash + git clone https://github.com/yourname/PRI_REPO.git + cd PRI_REPO + git remote add upstream https://github.com/exampleuser/PUB_REPO.git + git remote set-url --push upstream DISABLE # Optional + ``` + + - Pull updates from `upstream` via the following commands: + + ```bash + git pull upstream master # Creates a merge commit + ``` + + - Push to `PRI_REPO`: + + ```bash + git push origin master + ``` + +*References*: + +- [GitHub: How to make a fork of public repository private?](https://stackoverflow.com/questions/10065526/github-how-to-make-a-fork-of-PUB_REPOsitory-private) +- [Create a private fork of a public repository](https://gist.github.com/0xjac/85097472043b697ab57ba1b1c7530274) +- [Duplicating a repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository) ## 墙国专属 @@ -77,6 +199,10 @@ Get `hosts` from the following sites: - https://ineo6.github.io/hosts/ - https://github.com/isevenluo/github-hosts +*References*: + +- [修改 Hosts 解决 Github 访问失败马克](https://zhuanlan.zhihu.com/p/107334179) + ### Set proxy #### Linux @@ -85,6 +211,7 @@ Get `hosts` from the following sites: - [Configure Git to use a proxy](https://gist.github.com/evantoli/f8c23a37eb3558ab8765) - [Configure Git to use a proxy (https or SSH+GIT)](https://gist.github.com/ozbillwang/005bd1dfc597a2f3a00148834ad3e551) +- [Git设置代理服务器](https://blog.csdn.net/yanhanhui1/article/details/118769098) ### Other methods @@ -92,7 +219,10 @@ Get `hosts` from the following sites: - https://github.com/dotnetcore/FastGithub +## Interesting posts + +- [git里面的文件怎么删不掉_彻底删除git中没用的大文件](https://blog.csdn.net/weixin_33335559/article/details/112012325) + [//begin]: # "Autogenerated link references for markdown compatibility" -[notes-development/git]: ../../notes-development/git.md "Git Tips" [SSH#Generate SSH key]: remote/SSH.md "SSH Usage" [//end]: # "Autogenerated link references" diff --git a/notes-OS/cross-platform/hard_disk.md b/notes-OS/cross-platform/hard-disk.md similarity index 100% rename from notes-OS/cross-platform/hard_disk.md rename to notes-OS/cross-platform/hard-disk.md diff --git a/notes-OS/cross-platform/index.md b/notes-OS/cross-platform/index.md index 3bdd444..533aa2f 100644 --- a/notes-OS/cross-platform/index.md +++ b/notes-OS/cross-platform/index.md @@ -10,16 +10,16 @@ type: index - [[cross-platform/git]] - [[vscode]] - [[fonts]] -- [[hard_disk]] +- [[hard-disk]] - [[NVIDIA]] [//begin]: # "Autogenerated link references for markdown compatibility" -[shell]: ../Linux/cross-distro/shell-tools.md "Shell Related" -[terminal]: ../Linux/cross-distro/terminal-tools.md "Terminal Related" +[shell-tools]: ../Linux/cross-distro/shell-tools.md "Shell Related Tools" +[terminal-tools]: ../Linux/cross-distro/terminal-tools.md "Terminal Related Tools" [remote/index]: remote/index.md "Remote Development" -[cross-platform/git]: git.md "Git Configuration" +[cross-platform/git]: git.md "Git Usage Tips" [vscode]: VSCode.md "Visual Studio Code Tips" [fonts]: fonts.md "Fonts" -[hard_disk]: hard_disk.md "Hard Disk Manipulation" +[hard-disk]: hard-disk.md "Hard Disk Manipulation" [NVIDIA]: NVIDIA.md "NVIDIA Devices" [//end]: # "Autogenerated link references" diff --git a/notes-development/Docker.md b/notes-development/Docker.md index 8f77e06..5220c21 100644 --- a/notes-development/Docker.md +++ b/notes-development/Docker.md @@ -1 +1 @@ -# Develop Docker Application +# Docker Application Development diff --git a/notes-development/Java.md b/notes-development/Java.md new file mode 100644 index 0000000..3651cda --- /dev/null +++ b/notes-development/Java.md @@ -0,0 +1,5 @@ +# Java Development + +## Readings + +- [成为一个更好的Java程序员](https://github.com/crisxuan/bestJavaer) diff --git a/notes-development/git.md b/notes-development/git.md deleted file mode 100644 index ac90565..0000000 --- a/notes-development/git.md +++ /dev/null @@ -1,127 +0,0 @@ -# Git Tips - -This note contains operation related tips. See [[cross-platform/git]] for configuration tips. - -- [Commit message convention](#commit-message-convention) -- [Change commit messages](#change-commit-messages) -- [Clone to a specific directory](#clone-to-a-specific-directory) -- [Embedded repo](#embedded-repo) -- [Update an unchecked-out local branch from remote branch](#update-an-unchecked-out-local-branch-from-remote-branch) -- [Discard unstaged changes](#discard-unstaged-changes) -- [Stash changes](#stash-changes) -- [Rename branch](#rename-branch) -- [Change remote origin](#change-remote-origin) -- [Hard reset remote branch](#hard-reset-remote-branch) -- [Private fork](#private-fork) - -## Commit message convention - -*References*: - -- [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) - -## Change commit messages - -- Change the last one: `git commit --amend` -- [ ] Change multiple - -*References*: - -- [Changing a commit message](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/changing-a-commit-message) - -## Clone to a specific directory - -Use `git clone git@github.com:SOME_REPO TARGET_DIRECTORY`. - -*References*: - -- [How to 'git pull' into a branch that is not the current one?](https://stackoverflow.com/questions/651038/how-do-i-clone-a-git-repository-into-a-specific-folder) - -## Embedded repo - -*References*: - -- [Git: How to make outer repository and embedded repository work as common/standalone repository?](https://stackoverflow.com/questions/47008290/git-how-to-make-outer-repository-and-embedded-repository-work-as-common-standal) - -## Update an unchecked-out local branch from remote branch - -Use `git fetch REMOTE_REPO REMOTE_BRANCH:LOCAL_BRANCH`. - -## Discard unstaged changes - -- Discard all: `git restore .` -- Discard a specific file: `git restore PATH_TO_THE_FILE` - -*References*: - -- [How To Completely Reset a Git Repository (Including Untracked Files)](https://www.howtogeek.com/devops/how-to-completely-reset-a-git-repository-including-untracked-files/) - -## Stash changes - -- Stash changes by `git stash`. -- Pop stash by `git stash pop`. - -*References*: - -- [Git stash](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) - -## Rename branch - -- Rename checked-out local branch: Use `git branch --move NEW_BRANCH_NAME`. -- Rename unchecked-out local branch: Use `git branch --move BRANCH_NAME NEW_BRANCH_NAME`. - -## Change remote origin - -Use `git remote set-url REMOTE_NAME NEW_URL`. - -*References*: - -- [How To Change Git Remote Origin](https://devconnected.com/how-to-change-git-remote-origin/) - -## Hard reset remote branch - -After hard resetting the local repo, use `git push -f REMOTE_REPO BRANCH_NAME` to hard reset the remote repo. - -## Private fork - -1. Create a new repo (`PRI_REPO`) via the GitHub Website. -2. Duplicate the public repo (`PUB_REPO`) via the following commands: - - ```bash - git clone --bare https://github.com/exampleuser/PUB_REPO.git - cd PUB_REPO.git - git push --mirror https://github.com/yourname/PRI_REPO.git - cd .. - rm -rf PUB_REPO.git - ``` - -3. Clone the private repo and add `upstream` via the following commands: - - ```bash - git clone https://github.com/yourname/PRI_REPO.git - cd PRI_REPO - git remote add upstream https://github.com/exampleuser/PUB_REPO.git - git remote set-url --push upstream DISABLE # Optional - ``` - - - Pull updates from `upstream` via the following commands: - - ```bash - git pull upstream master # Creates a merge commit - ``` - - - Push to `PRI_REPO`: - - ```bash - git push origin master - ``` - -*References*: - -- [GitHub: How to make a fork of public repository private?](https://stackoverflow.com/questions/10065526/github-how-to-make-a-fork-of-PUB_REPOsitory-private) -- [Create a private fork of a public repository](https://gist.github.com/0xjac/85097472043b697ab57ba1b1c7530274) -- [Duplicating a repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository) - -[//begin]: # "Autogenerated link references for markdown compatibility" -[cross-platform/git]: ../notes-OS/cross-platform/git.md "Git Configuration" -[//end]: # "Autogenerated link references" diff --git a/notes-development/index.md b/notes-development/index.md index 398f16f..0d273f7 100644 --- a/notes-development/index.md +++ b/notes-development/index.md @@ -7,13 +7,13 @@ type: index ## General tips - [[notes-development/tips]] -- [[notes-development/git]] ## Programming languages - [[C]] - [[CPP]] - [[Flutter]] +- [[Java]] - [[LaTeX/index]] - [[Python]] - [[Rust]] @@ -28,10 +28,10 @@ type: index [//begin]: # "Autogenerated link references for markdown compatibility" [notes-development/tips]: tips.md "General Development Tips" -[notes-development/git]: git.md "Git Tips" [C]: C.md "C" [CPP]: CPP.md "C++" [Flutter]: Flutter.md "Flutter" +[Java]: Java.md "Java Development" [LaTeX/index]: LaTeX/index.md "$\LaTeX$" [Python]: Python.md "Python" [Rust]: Rust.md "Rust" @@ -39,5 +39,5 @@ type: index [decentralization]: decentralization.md "Decentralization Related" [ML]: ML.md "Machine Learning" [Android]: Android.md "Android" -[notes-development/Docker]: Docker.md "Develop Docker Application" +[notes-development/Docker]: Docker.md "Docker Application Development" [//end]: # "Autogenerated link references" diff --git a/notes-development/tips.md b/notes-development/tips.md index 9dbf85c..1f66ea3 100644 --- a/notes-development/tips.md +++ b/notes-development/tips.md @@ -10,8 +10,8 @@ ## Git commit message convention -See [[notes-development/git#Commit message convention]]. +See [[cross-platform/git#Commit message convention]]. [//begin]: # "Autogenerated link references for markdown compatibility" -[notes-development/git#Commit message convention]: git.md "Git Tips" +[cross-platform/git#Commit message convention]: ../notes-OS/cross-platform/git.md "Git Usage Tips" [//end]: # "Autogenerated link references"