Skip to content

Instantly share code, notes, and snippets.

@arvati
Last active April 20, 2024 17:06
Show Gist options
  • Save arvati/d8ceb00f85df12268c0bfa2438971dc5 to your computer and use it in GitHub Desktop.
Save arvati/d8ceb00f85df12268c0bfa2438971dc5 to your computer and use it in GitHub Desktop.
Backup Files with Git Protocol

Backup Files with Git Protocol

Setup gpg password (optional)

nano ~/.gnupg/gpg-agent.conf
default-cache-ttl 34560000
max-cache-ttl 34560000
allow-preset-passphrase
/usr/bin/gpg-connect-agent reloadagent /bye
gpg --list-keys --with-keygrip
/usr/libexec/gpg-preset-passphrase --preset --passphrase <passwd> <keygrip-above>
#git-bash => /usr/lib/gnupg/gpg-preset-passphrase --preset --passphrase <passwd> <keygrip-above>
git config --global commit.gpgsign true
git config --global user.email "email"
git config --global user.name "name"
git config --global user.signingkey <hash>

Create Bare Repo

sudo git init --bare --shared=all /srv/git/familia.git
cd /srv/git/familia.git/
sudo git config core.sharedRepository group
sudo chgrp -R users . 
sudo chmod -R g+w . 
sudo chmod g-w objects/pack/* 
sudo find -type d -exec chmod g+s {} + 

Config remote origin

git remote add origin git@ssh.dev.azure.com:v3/<ok>/<project>/Familia
git config --add remote.origin.fetch +refs/*:refs/*
git config --add remote.origin.mirror true

Create Local Git

cd /mnt/data/media/Users
sudo git init --shared=all
sudo git config core.sharedRepository group
sudo chgrp -R users . 
sudo chmod -R g+w . 
sudo chmod g-w .git/objects/pack/* 
sudo find -type d -exec chmod g+s {} + 

Config remote origin

git remote add origin git://vcs.casa/familia.git
git remote add upstream git@ssh.dev.azure.com:v3/<ok>/<project>/Familia

Add initial files

echo ' ' >> .gitignore
echo '* -text' >> .gitattributes 
git add .gitignore .gitattributes 
git commit -a -S -m 'Signed initial commit'
git push --set-upstream origin master
git push origin --all
git push origin --tags

Commit one file at a time and push it

screen
git ls-files -z -o --exclude-standard | xargs -i ash -c "git add '{}'; git commit -a -S -m 'added file {}'; git push origin"

Push one commit at a time

cd /srv/git/familia.git/
screen
for c in $(git rev-list --all --reverse --branches master); do git push origin $c:refs/heads/master ; done
# if stop while not finished ...
for c in $(git rev-list d06731c9229863e57b23b325a7e45cf2c753132c..HEAD --reverse --branches master); do git push origin $c:refs/heads/master ; done

@arvati
Copy link
Author

arvati commented May 24, 2020

https://stackoverflow.com/questions/38384957/prevent-git-from-asking-for-the-gnupg-password-during-signing-a-commit
https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html

nano ~/.gnupg/gpg-agent.conf
default-cache-ttl 34560000
maximum-cache-ttl 34560000
allow-preset-passphrase
/usr/bin/gpg-connect-agent reloadagent /bye
gpg --list-keys --with-keygrip
/usr/libexec/gpg-preset-passphrase --preset --passphrase <passwd> <keygrip-above>

@arvati
Copy link
Author

arvati commented Apr 8, 2022

git bash
git ls-files -z -o --exclude-standard | xargs --null -i sh -c "git add '{}'; git commit -a -S -m 'added file {}'; git push origin"

@arvati
Copy link
Author

arvati commented Apr 20, 2024

for c in $(git rev-list f2fb9a04a7d8a575e9f2ae67438a7066a2ecb3f5..HEAD --reverse --branches master); do git push origin $c:refs/heads/master ; done
for c in $(git rev-list --all --reverse --branches master); do git push upstream $c:refs/heads/master ; done

@arvati
Copy link
Author

arvati commented Apr 20, 2024

Pull one commit at a time

git fetch upstream && git merge $(git rev-list master..upstream/master | tail -n1) 

review bellow before use ....

git fetch upstream && for rev in $(git rev-list --reverse master..upstream/master); do git merge upstream/master $rev:master; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment