Git¶
Git¶
Git game in Learn Git Branching
Init¶
Auth¶
git config --global user.name "A.J.Zeller"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main
git config credential.helper
SSH¶
in admin powershell
Start Ssh-agent¶
Generate Key-pair¶
ssh-keygen -t ed25519 -C "[email protected]"
in normal powershell
Add Ssh-key-pair into Ssh-agent¶
Copy id_ed25519.pub into github_ssh_setting Set Auth Key Type¶
Test Ssh Connect by Https¶
ssh -T -p 443 [email protected]
Add Config¶
add the following text into ~/.ssh/config
windows in c:\user\your_user_name\.ssh\config
Host github.com
Hostname ssh.github.com
Port 443
User git
# 30327 is your local proxy port
ProxyCommand nc -X connect -x 127.0.0.1:30327 %h %p
Test Test Ssh Connect¶
you may need to enter yes as it's requiring to trust connection to github
Remote¶
list remote repo
add remote
associate remote
set https to ssh
Remove Track¶
Roll back¶
# force roll back some commit
git reset --hard <commit hash>
# force push remote
git push origin main -f
Sync from Github¶
Submodule¶
clone with submodule
git clone --recurse-submodules <repository-url>
# if forget to with params --recurse-submodules try following
git submodule update --init --recursive
add submodule or clone in main as submodule
git submodule add <repository-url> <sub_repo_relative_path_to_root>
# if no .gitsubmodules appears try it
git submodule update --init --recursive
remove
Modify Git Commit Messages¶
open rebase editor with 4 latest commit
replace pick with edit and save.
start to edit commit message.
save the results
Update PR from Main¶
git checkout -b backup-branch
# under your-feature-branch
git checkout your-feature-branch
# rest to main
git fetch upstream
git reset --hard upstream/dev-next
# pick new commit
git cherry-pick backup-branch
git push -f origin
Tags¶
delete latest tag
git tag -d $(git describe --abbrev=0 --tags)
# check if deleted
git tag -l
# force to update tags
git push origin main --tags -f
# delete tags both local and remote
git tag -d v1.12.14
git push origin --delete v1.12.14
git ls-remote --tags origin
add tags via vscode git plugin