git - Serbipunk/notes GitHub Wiki
dead simple version
https://backlog.com/git-tutorial/tw/stepup/stepup2_3.html
best tutorial https://backlog.com/git-tutorial/tw/ https://backlog.com/git-tutorial/cn/stepup/stepup1_1.html
git clone --single-branch --branch <branchname> <remote-repo>
https://stackoverflow.com/questions/1911109/how-do-i-clone-a-specific-git-branch
https://www.youtube.com/watch?v=jhl7ruTPV-o
keep submodule updated
example:
the github branch prompts as follows
Submodule [ilab-sdk](https://github.com/zozonz/ilab-sdk) updated [from bfed72 to ddaa24](https://github.com/zozonz/ilab-sdk/compare/bfed72eadb347d1f6614e8c8177e6d87297b0e70...ddaa24730a7b3b7def1837fcc8db494943550390)
cd ilab-sdk/
git checkout main
git checkout bfed72
1 save change and return to HEAD
git stash save "Your stash message"
2 check stash list
git stash list
3 apply the stash
git stash apply stash@{0}
https://youtu.be/i657Bg_HAWI?feature=shared
one commit
git cherry-pick $(
hash code of the commit)
multiple commits
git cherry-pick $(
START_COMMIT_HASH) $(
END_COMMIT_HASH)
direct run and failed
The following paths are ignored by one of your .gitignore files:
CMakeLists.txt
Use -f if you really want to add them.
git add -v -f iceberg/static/icon
$ git config --[system|global|local] --list
https://www.jianshu.com/p/1ae2ff6c90de
git config --local user.email "[email protected]"
git config --local user.name baimr
a melt-pot like doc
https://stackoverflow.com/questions/1519006/how-do-you-create-a-remote-git-branch
git checkout <existing branch>
git checkout -b your_branch
git push -u origin your_branch
git fetch
git checkout origin/your_branch
( for single-branch version (https://stackoverflow.com/a/60846265)
git remote set-branches --add origin [remote-branch]
git fetch
git checkout [remote-branch]
)
git checkout develop
git pull
git checkout feat/color_transfer_blush_and_eye
git merge develop
git checkout master
git pull origin master
git merge test
git push origin master
https://stackoverflow.com/questions/67699/how-to-clone-all-remote-branches-in-git
https://stackoverflow.com/questions/278192/view-the-change-history-of-a-file-using-git-versioning
gitk [filename]
or
gitk --follow [filename]
git config --global http.proxy "socks5://127.0.0.1:7891"
cancel proxy
git config --global --unset https.proxy
https://blog.csdn.net/baidu_36482169/article/details/82818490 https://gist.github.com/laispace/666dd7b27e9116faece6
git diff --name-only HEAD..b7b8d042
https://www.cyberithub.com/3-best-ways-to-list-all-the-changed-files-after-git-commit/
To remove & delete all changes git clean -d -f
https://stackoverflow.com/a/49442999
https://youtu.be/govmXpDGLpo?feature=shared
git tag <tag name>
example git tag -a -v1.0 -m "ver 1 of ..."
git tag
git show v1.0
git tag -l ""
git push origin v1.0
git tag -d v1.0
or git tag --delete v1.0
git push origin -d v1.0
git tag <tag name> <reference of commit>
git checkout -- tools/ilab-makeup-transfer-tool-runner/test_data/transfer
gpt full answer
You can recover the deleted tools/ilab-makeup-transfer-tool-runner/test_data/transfer directory, especially if it is tracked by Git and Git LFS. Here are the steps:
1. Check for Local Changes and Commits
If you only deleted the directory locally but haven't committed the changes, you can easily recover it using:
git checkout -- tools/ilab-makeup-transfer-tool-runner/test_data/transfer
2. Check the Commit History
If the directory was deleted in a previous commit, identify when it was last available:
git log -- tools/ilab-makeup-transfer-tool-runner/test_data/transfer
Look for the last commit where this directory existed.
3. Recover from a Previous Commit
Once you have the commit hash where the directory was last present, use:
git checkout <commit_hash> -- tools/ilab-makeup-transfer-tool-runner/test_data/transfer
This restores the directory as it was in that commit.
4. Recover Files Tracked by Git LFS
If some files were tracked with Git LFS, ensure Git LFS is installed and properly initialized:
git lfs install
After restoring the directory using git checkout, run:
git lfs pull
This will download the LFS-tracked files back into the restored directory.
5. Commit the Recovered Directory (Optional)
If needed, you can commit the recovered directory to your branch:
git add tools/ilab-makeup-transfer-tool-runner/test_data/transfer
git commit -m "Restore transfer directory"
This will ensure the restored files are properly tracked again.
gpt's answer:
To recover from committing without pulling the latest changes from the remote, follow these steps to properly integrate your changes:
Fetch the latest changes from the remote repository:
git fetch origin
Check the difference between your local branch and the remote:
git log origin/your-branch..your-branch
This will show you the commits that are different between your local and the remote branch.
Rebase your local commit onto the latest remote changes:
git pull --rebase origin your-branch
This will replay your local commit (eee449b9114ef4830b7b9e2b2c436f47b38363e1) on top of the fetched changes, avoiding a merge commit.
If there are conflicts, Git will stop and let you resolve them. Resolve any conflicts, then continue the rebase:
git rebase --continue
After the rebase completes, push your changes to the remote:
git push origin your-branch
By following these steps, your commit will be recovered, and your changes will be integrated with the latest updates from the remote repository.
git push --force-with-lease origin feat/heads_and_loss
before rebase
after rebase
git lfs install
git lfs track "tests/data/body_shape_test_data/records.json"
git rm --cached tests/data/body_shape_test_data/records.json
git add tests/data/body_shape_test_data/records.json
git add .gitattributes