Skip to content
Davood Dorostkar edited this page May 29, 2023 · 3 revisions

Make Git server

  1. If the user is important, switch to the target user:
su theUser
  1. SSH keys must be in authorized keys, if not set previously. for adding open it:
nano ~/.ssh/authorized_keys
  1. Make the repository as the remote server:
git init --bare repository.git
  1. 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

Remove history

To remove all history but the creation date and last commit:

get the creation date

inside current repo check the creation date

git log --reverse

clone repo

clone only the last commit:

git clone --no-hardlinks --depth=1 URL NEW_DIRECTORY
cd NEW_DIRECTORY

check size & last commit

du -sh .git
git log

create an orphan branch

git checkout --orphan new-root

make commit

git add .
git commit -m 'removed repo history'

change repo creation date

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

check date

git log --reverse

update branches

git remote remove origin
git remote add origin URL
git branch -D master

change your current branch name

git branch -m new-root main

update remote repo

git push --set-upstream origin main
git push origin --delete master