Skip to content
tamaszl edited this page Sep 21, 2021 · 7 revisions

How to extract configurations from bare git repository

root@oxidize:~# cd /etc/oxidized/git-reports/Rotuers.git
root@oxidize:/etc/oxidized/git-repos/Routers.git# git worktree list --porcelain
worktree /etc/oxidized/git-repos/Routers.git
bare

root@oxidize:/etc/oxidized/git-repos/Routers.git# git worktree add --checkout ../test
Preparing ../test (identifier test)
HEAD is now at c1f66627
root@oxidize:/etc/oxidized/git-repos/Routers.git# ls -l ../test
total 21M
drwxr-x--- 2 root root 28K Jan 31 15:03 .
drwx------ 12 root root 4.0K Jan 31 14:53 ..
-rw-r----- 1 root root 160 Jan 31 14:48 192.168.180.160
-rw-r----- 1 root root 160 Jan 31 14:48 192.168.180.161
-rw-r----- 1 root root 22K Jan 31 15:03 6450sw514a.lax1
-rw-r----- 1 root root 55K Jan 31 15:03 6610sw01a.phx1
-rw-r----- 1 root root 20K Jan 31 15:03 6610sw19a.phx1
-rw-r----- 1 root root 21K Jan 31 15:03 7450sw20a.phx1
-rw-r----- 1 root root 26K Jan 31 15:03 7750sw01a.phx1
-rw-r----- 1 root root 26K Jan 31 15:03 7750sw01b.phx1
-rw-r----- 1 root root 24K Jan 31 15:03 7750sw1007ab.lax10
-rw-r----- 1 root root 25K Jan 31 15:03 7750sw20a.phx1
-rw-r----- 1 root root 25K Jan 31 15:03 7750sw20b.phx1
-rw-r----- 1 root root 24K Jan 31 15:03 7750sw407.iad2
-rw-r----- 1 root root 31K Jan 31 15:03 asw108.lax10

How to reduce the size of your git repo

Backup Repo

root@oxidize:/etc/oxidized/git-repos/Firewalls.git# git clone . /root/test/
Cloning into '/root/test'...
done.
root@oxidize:/etc/oxidized/git-repos/Firewalls.git# cd /root/test

Clean up Repo

1.1G    .
root@oxidize:/etc/oxidized/git-repos/Switches.git# git gc --aggressive
Counting objects: 136862, done.
^@Delta compression using up to 8 threads.
Compressing objects: 100% (136861/136861), done.
Writing objects: 100% (136862/136862), done.
Total 136862 (delta 85926), reused 0 (delta 0)
Removing duplicate objects: 100% (256/256), done.
Checking connectivity: 136868, done.
root@oxidize:/etc/oxidized/git-repos/Switches.git# du -h
19M ./objects/pack
44K ./objects/6f
8.0K    ./objects/info
16K ./objects/74
44K ./objects/8e
52K ./objects/26
48K ./objects/f3
8.0K    ./objects/9b
19M ./objects
8.0K    ./refs/heads
4.0K    ./refs/tags
16K ./refs
8.0K    ./hooks
12K ./info
19M .

Sync Local Git to Remote Git

Add your ssh-key to Gitlab

config file change output

output:
  default: git
  git:
    user: "your name"
    email: [email protected]
    repo: "/home/oxidized/.config/oxidized/oxidized.git"
cd /home/oxidized/.config/oxidized/oxidized.git
git config --global user.name "your name"
git config --global user.email "[email protected]"
git remote add origin [email protected]:yourgitrepousername/oxidized.git
git push -u origin master