[Oberon] Re (2): Git usage for A2.

Michael Schierl schierlm at gmail.com
Sat Jun 24 13:53:30 CEST 2023


[[re-sending this from my Gmail account since my primary address's 
provider seems to be blocked to send to the mailing list due to an 
expired Spamhaus listing. Apologies if you receive it twice.]]


Hello,


Am 23.06.2023 um 04:19 schrieb peter at easthope.ca:

> After finding https://git-scm.com/docs/git-remote I wonder
> why git clone https://gitlab.inf.ethz.ch/felixf/oberon.git
> works before
> git remote add https://gitlab.inf.ethz.ch/felixf/oberon.git

"git clone" is just a convenience command that calls "git init", "git 
remote add", "git fetch" and "git checkout" with the most common options 
(in addition to making a new directory for your repository if you did 
not specify an existing empty one). There are cases where you need 
options that are not exposed by "git clone" so you have to go the long 
route.

In particular, it does not matter if you do in an empty directory

git clone https://foo .
git remote rename origin foo
git remote add bar https://bar
git fetch bar
git checkout -b somebranch --track bar/somebranch
git branch -D main

or

git clone https://bar .
git remote rename origin bar
git remote add foo https://foo
git fetch foo
git checkout -b somebranch --track bar/somebranch
git branch -D main

or

git init
git remote add foo https://foo
git remote add bar https://bar
git fetch foo
git fetch bar
git checkout -b somebranch --track bar/somebranch
git branch -D main


Afterwards you have the same repository with the same branches and 
files, regardless which one you cloned first (if any). I deleted the 
main branch since it points to the main branch of the repository you 
cloned from, or an empty orphan branch in case of "git init".

>>From a little reading, the large file repository is separate from the 
> git repository.

Even without lfs, you have
- your local repository (oberon/.git)
- your working tree (oberon/* without .git)
- one or more remote repositories

Note that your local repository contains local branches (where you can 
commit to) as well as remote branches (which mirror the contents of a 
remote repository at the point in time you fetched the remote last time).

> fetch brings a large file to my large file repository whereas checkout
> makes the large file available in the git repository?

fetch (lfs or not) loads data from a remote repository to your local 
repository, and checkout makes data from your local repository available 
in your work tree. The lfs commands use the same nomenclature, i. e. 
"lfs fetch" will download large files to your local repository while 
"lfs checkout" will make them available in your work tree.

(For completeness, "add" will move changes from your working tree to 
your staging area, "commit" will move from your staging area and/or 
worktree to your local repository, and "push" will move from your local 
repository to remote repositories. "pull" is a convenience command for 
"fetch" followed by either "merge" or "rebase").


Regards,


Michael


More information about the Oberon mailing list