Keeping Files Synchronized (Github)

Keeping a project / files synchronized while working on different machines (or like I have a multiboot with MacOS and Fedora).

Create a local repo

Start a new project with at the root

git init

Do your stuff and

git add .
git commit -m "<message>"

Create a remote repo

Using github cli client gh

gh repo create

and follow instructions. Select if the repo will be public or private

Another way:

gh repo create <repo_name> --private

git remote add origin [email protected]:<user_name>/<repo_name>.git

git push -u origin master

There will be a new remote repo named <repo_name> on github.com

To synchronize

On the other distro / machine

gh repo clone <repo_name>

Work on the local copy. When done git push

From now, on either machine / distro start with git pull and on completion git push.

In Linux after git push github requested a password. Solved by changing to ssh.

git remote set-url origin [email protected]:<github-name>/<repo-name>.git

git remote set-url origin [email protected]:medevdk/dotfiles.git

Lazygit

I have started using Lazygit, some commands to memorize:

q:          quit
p:          pull
shift + P:  push

Files Panel:
c:          commit
o:          open
e:          edit
v:          open in vs code
i:          add to .gitignore
shift + R   refresh files
Git series
All posts in Git
  1. Git(hub)
  2. Keeping files synchronized (github)
  3. Branching with git (basic)