MareArts ANPR mobile app

Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

4/15/2024

git tip, delete all history (commit) information

 



.

# Warning: This will destroy your current history.

# Ensure that you understand the consequences before running these commands.


# Go to your repository directory

cd path/to/your/repository


# Create a new initial commit

git checkout --orphan newBranch

git add -A

git commit -m "Initial commit"


# Delete the main branch

git branch -D main


# Rename the current branch to main

git branch -m main


# Force push to overwrite the history on the remote repository

git push --force origin main


..

4/12/2024

Check amout of size with consider .gitignore files.

Put this cmd. 


git ls-files \

  | xargs du -ch \

  | grep total$



Thank you!

2/08/2024

git find large big file which committed.

 Find large file in GitHub repository

.

git rev-list --objects --all | \
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | \
awk '$3 > 100*1024*1024' | sort -k3nr


..

  • git rev-list --objects --all lists all objects in the repository.
  • git cat-file --batch-check='...' checks the type, size, and other details of these objects.
  • awk '$3 > 100*1024*1024' filters objects larger than 100 MB (note: 1024*1024 bytes = 1MB).
  • sort -k3nr sorts these objects by size in descending order.

🙇🏻‍♂️

9/01/2022

Delete 100mb file in all committed history in git

 Let's say the problem which is more than 100mb file is "shit.pt"

And you want to delete already committed in git history and you don't push and reverting.

Then this is save you


> git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch SHIT.bin' --prune-empty --tag-name-filter cat -- --all


Change SHIT.bin file name as your problem guy. 

And add .gitignore and commit & push.

Thank you.

www.marearts.com



1/12/2022

git : How to remove a big file wrongly committed



error message:

remote: Resolving deltas: 100% (23/23), completed with 8 local objects.
remote: error: Trace: 2ffe6017a58c483deb760c27365127df2f67946ddad23f7e84f265b42c275992
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File xxxx.ckpt is 206.67 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.


solution

git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD
git push

4/20/2021

error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8) fatal: the remote end hung up unexpectedly

 

I encounter this error when I push my repo.


>>>

error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)

fatal: the remote end hung up unexpectedly

<<<


I am trying following things to solve, It comes from stack overflow.


1.

git config --global http.version HTTP/1.1
git push 
git config --global http.version HTTP/2


2.

git config http.postBuffer 524288000



I tired both, but I failed.

In luck you could success.


Thank you.


12/23/2020

delete over than specific megabyte in git history using bfg

firstly, install bfg


on mac

> brew install bfg

delete object if over than 50m in git commit history

> bfg --strip-blobs-bigger-than 50M

make sure & apply .gitignore





First, to check what files are you actually tracking
> git ls-tree --name-only --full-tree -r HEAD


Let say that you found unwanted files in a directory like cache/ so, it's safer to target that directory instead of all of your files.
So instead of:

> git rm -r --cached .


It's safer to target the unwanted file or directory:
> git rm -r --cached cache/


Then proceed to add all changes:
> git add .


and commit
> git commit -m ".gitignore is now working"

list up and sorting file(object) size in git / command

 use following cmd:

> git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | sed -n 's/^blob //p' | sort --numeric-sort --key=2 | cut -c 1-12,41- | $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest