-
Notifications
You must be signed in to change notification settings - Fork 0
07_Git
Davood Dorostkar edited this page May 29, 2023
·
3 revisions
- If the user is important, switch to the target user:
su theUser
- SSH keys must be in authorized keys, if not set previously. for adding open it:
nano ~/.ssh/authorized_keys
- Make the repository as the remote server:
git init --bare repository.git
- In the client side, clone the repo (considering the repo is in the
home
of a linux system. for windows server, I do not know the path structure). Example:
git clone user@192.168.100.18:repository.git
To remove all history but the creation date and last commit:
inside current repo check the creation date
git log --reverse
clone only the last commit:
git clone --no-hardlinks --depth=1 URL NEW_DIRECTORY
cd NEW_DIRECTORY
du -sh .git
git log
git checkout --orphan new-root
git add .
git commit -m 'removed repo history'
change the date to your desired date (in the first step)
git filter-branch --env-filter 'if [ "$GIT_COMMIT" = "$(git rev-list --max-parents=0 HEAD)" ]; then export GIT_AUTHOR_DATE="2022-11-11 12:00:00"; export GIT_COMMITTER_DATE="2022-11-11 12:00:00"; fi' new-root
git log --reverse
git remote remove origin
git remote add origin URL
git branch -D master
git branch -m new-root main
git push --set-upstream origin main
git push origin --delete master