How can I manage dotfiles repo push/pull automatically? (or w/ scripts)

237 views Asked by At

Introduction

Hi I'm trying to manage my dotfiles repository between my linux computer and my codeberg account

  • I have my dotfiles repo on my computer
  • I'd like to use the automatic push/pull changes function of codeberg
  • The repository on codeberg is private

Problems

Do you know any way of solving these 2 issues?

Problem 1 #Security #Syncing #Authorization

How can I manage to clone/push/pull (make changes in general) on the codeberg repository without having the credentials asked each time? I've heard about "setting SSH keys" but I don't know how to do that

This could create me problems, when trying to set up automation scripts

Problem 2

How can I setup an automatic push/pull repository, without having conflicts?

For example, if I change 2 files, or even the same one, one on my computer through emacs, and the other one on codeberg through my browser.

  • I could just sync the org files and not the actual data folders

I'd like to know how to avoid completely those situations (to reduce the number of things to manage) or a safe way to manage this things, through codeberg functions or bash script which I'd run through Cron

Informations

While trying to clone the private repo, I cannot get rid of the credential asking phase, plus, I have no idea how to avoid conflicts between commit versions (local-codeberg)

1

There are 1 answers

0
VonC On

Regarding SSH, the process is explained at coddebarg's page "Adding an SSH key to your account".

But make sure to use an SSH URL then:

[email protected]:you/yourRepository

I would then recommend (since Git 2.27, Q2 2020) to setup:

git config --global pull.rebase true
git config --global rebase.autoStash true

That way, a simple git pull before pushing will force you to replay your local commits on top of origin/main (if you were on main branch): any merge conflict would be resolved then.
After the pull, you can push.