git
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
git [2023/11/14 12:13] – [overwriting the remote history in GIT repo] skipidar | git [2023/11/30 09:11] (current) – [Remove unreachable blobs] skipidar | ||
---|---|---|---|
Line 69: | Line 69: | ||
</ | </ | ||
- | {{http://i520.photobucket.com/albums/ | + | {{https://s3.eu-central-1.amazonaws.com/alf-digital-wiki-pics/ |
Line 111: | Line 111: | ||
- | ==== Initial Setup ===== | + | ==== Initial Setup on Windows |
- | Store the data in "C: | + | == .gitconfig == |
+ | |||
+ | File: | ||
+ | '' | ||
+ | |||
+ | You can use the cmd to config git. | ||
+ | Tell it the default user name / mail | ||
< | < | ||
Line 119: | Line 125: | ||
git config --global user.email johndoe@example.com | git config --global user.email johndoe@example.com | ||
</ | </ | ||
+ | |||
+ | == .ssh\config == | ||
+ | |||
+ | File: | ||
+ | '' | ||
+ | |||
+ | Configure ssh to use e.g. the github-key for github url. | ||
+ | |||
+ | * Use the ''/'' | ||
+ | * Use quotes ''"'' | ||
+ | |||
+ | |||
+ | <sxh shell> | ||
+ | Host github.com | ||
+ | Hostname github.com | ||
+ | User git | ||
+ | IdentityFile "/ | ||
+ | </ | ||
+ | |||
Line 181: | Line 206: | ||
</ | </ | ||
- | |||
- | ===Assembla=== | ||
- | **Summary: | ||
- | - Assembla has SSH Key authtication. It can be generated with Putty - the public key is uploaded here: https:// | ||
- | - Then you should create a remote entry with yout Assembla email and private key under < | ||
- | - Do the "Git Clone" somehwere | ||
- | |||
- | The details are here: http:// | ||
Line 240: | Line 257: | ||
==== Rebase ===== | ==== Rebase ===== | ||
- | <code> | + | <sxh shell> |
Line 281: | Line 298: | ||
git push --force-with-lease | git push --force-with-lease | ||
- | </code> | + | </sxh> |
+ | |||
+ | |||
+ | ==== Getting rid of Git History ===== | ||
+ | |||
+ | https:// | ||
+ | |||
+ | <sxh shell> | ||
+ | |||
+ | |||
+ | # first backup your history by copying the branch. | ||
+ | # can remove it later | ||
+ | git switch master | ||
+ | git branch master_history_2023_11_31 | ||
+ | git push origin -u master_history_2023_11_31 | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | # Checkout as orphan, without history | ||
+ | git checkout --orphan latest_branch | ||
+ | |||
+ | # Add all the files | ||
+ | git add -A | ||
+ | |||
+ | # Commit the changes | ||
+ | git commit -am " | ||
+ | |||
+ | # Delete the branch | ||
+ | git branch -D master | ||
+ | |||
+ | # Rename the current branch to master | ||
+ | git branch -m master | ||
+ | |||
+ | # Finally, force update your repository | ||
+ | git push -f origin master | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==== Deleting branch | ||
+ | |||
+ | Delete branch '' | ||
+ | |||
+ | <sxh shell> | ||
+ | |||
+ | git branch -D latest_branch | ||
+ | |||
+ | git push origin --delete latest_branch | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== Remove unreachable blobs, reduce size of repo ===== | ||
+ | |||
+ | '' | ||
+ | |||
+ | |||
+ | Sometimes in '' | ||
+ | Even if you removed the history on the current branch, they might persist blowing up the repo. | ||
+ | |||
+ | To clean them up - use the garbage collector. | ||
+ | |||
+ | <sxh shell> | ||
+ | |||
+ | # This command is used to expire all entries in the reflog that are not reachable from the current commit (i.e., entries that are not part of any branch or tag). The --expire-unreachable=all flag specifies that even unreachable entries (such as commits that were " | ||
+ | # The --all flag ensures that it applies to all branches and tags, not just the current branch. | ||
+ | git reflog expire --expire-unreachable=all --all | ||
+ | |||
+ | |||
+ | |||
+ | # This command triggers Git's garbage collection process (gc stands for " | ||
+ | |||
+ | git gc --prune=all | ||
+ | </sxh> |
git.1699963992.txt.gz · Last modified: by skipidar