Recent

Author Topic: How to use git  (Read 12874 times)

BosseB

  • Sr. Member
  • ****
  • Posts: 468
How to use git
« on: November 22, 2021, 11:09:15 am »
I see that fpcupdeluxe has had problems when the svn source server was shutdown and gitlab was started in its place....
I also have this problem with downloading release versions of fpc and lazarus sources.

I would be very grateful if someone here who knows how the gitlab functions could tell me what is the correct URL to the releases of lazarus and fpc sources.

I have spent hours trying to figure this out to no avail.
I am not a user of GIT so I know very little except when one clones a repository one gets ALL of the total history downloaded and that will be HUGE!
My existing scripts just issue a svn export for the svn release tag I want and then I get just those files.
AFAICU svn is capable of getting sources from GIT provided opne has the correct URL and this is what I have tried many hours now to find in vain....

So please give me a working example URL for Lazarus 2.0.12 and FPC 3.2.0

Ever grateful if this is provided!
--
Bo Berglund
Sweden

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: How to use git
« Reply #1 on: November 22, 2021, 12:11:37 pm »
1. $ git clone -b lazarus_2_0_12 https://gitlab.com/freepascal.org/lazarus/lazarus.git laz2012

2. $ git clone -b release_3_2_0 https://gitlab.com/freepascal.org/fpc/source.git fpc320

This only downloads the specified branch. Simples :)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5462
  • Compiler Developer
Re: How to use git
« Reply #2 on: November 22, 2021, 01:28:16 pm »
I am not a user of GIT so I know very little except when one clones a repository one gets ALL of the total history downloaded and that will be HUGE!

A complete clone of the FPC repository has roughly the same size as a checkout of SVN trunk with the added benefit that you have the whole history available and that you can add multiple working directories based on the same clone (so you only have to do the full checkout once).

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: How to use git
« Reply #3 on: November 22, 2021, 01:46:42 pm »
1. $ git clone -b lazarus_2_0_12 https://gitlab.com/freepascal.org/lazarus/lazarus.git laz2012

2. $ git clone -b release_3_2_0 https://gitlab.com/freepascal.org/fpc/source.git fpc320

This only downloads the specified branch. Simples :)

So how do you find the tag names you used in the commands above?
All I find when navigating to gitlab and open the lazarus tags page are names like:
main-1_9
main-2_1
main-2_3

Nowhere I have looked do I see names like lazarus_2_0_12 or release_3_2_0
In the old repository I could navigate to a page where the actual tags were listed, is there no such page in GitLab?
--
Bo Berglund
Sweden

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9855
  • Debugger - SynEdit - and more
    • wiki
Re: How to use git
« Reply #4 on: November 22, 2021, 03:38:18 pm »
AFAICU svn is capable of getting sources from GIT provided opne has the correct URL and this is what I have tried many hours now to find in vain....
I am not aware of this (but neither do I know that it is not so). But GitHUB offers svn access. And there are official mirrors on GitHub: https://github.com/fpc

However, the SVN feature is something provided by GitHub. We have no influence how GitHub does this, or what the result is, and there is no official support for SVN access. Nor can the SVN commit numbers be used for reference of any kind (e.g. bug reports).


GitLab (as well as GitHub) offers several methods of access.

Without GIT
Download a revision (e.g. with "wget"):
https://gitlab.com/freepascal.org/lazarus/lazarus/-/archive/main/lazarus-main.tar
https://gitlab.com/freepascal.org/lazarus/lazarus/-/archive/main/lazarus-main.tar.bz2
https://gitlab.com/freepascal.org/lazarus/lazarus/-/archive/main/lazarus-main.tar.gz
https://gitlab.com/freepascal.org/lazarus/lazarus/-/archive/main/lazarus-main.zip

branches
https://gitlab.com/freepascal.org/lazarus/lazarus/-/archive/main/lazarus-main.zip
https://gitlab.com/freepascal.org/lazarus/lazarus/-/archive/fixes_2_2/lazarus-fixes_2_2.zip
tags
https://gitlab.com/freepascal.org/lazarus/lazarus/-/archive/lazarus_2_2_0_RC2/lazarus-lazarus_2_2_0_RC2.zip
commit
https://gitlab.com/freepascal.org/lazarus/lazarus/-/archive/6708a746c871db34cf87de0ca4ce8d6368cf5155/lazarus-6708a746c871db34cf87de0ca4ce8d6368cf5155.zip


With GIT
- view all branches (without needing to download the repo)
Code: Bash  [Select][+][-]
  1. git ls-remote https://gitlab.com/freepascal.org/lazarus/lazarus.git

- to get the one commit only
Code: Bash  [Select][+][-]
  1. git init
  2. git fetch --depth=1 https://gitlab.com/freepascal.org/lazarus/lazarus.git  fixes_2_2
  3. git switch fixes_2_2
  4.  



MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: How to use git
« Reply #5 on: November 22, 2021, 03:55:25 pm »
With GIT
- view all branches (without needing to download the repo)
Code: Bash  [Select][+][-]
  1. git ls-remote https://gitlab.com/freepascal.org/lazarus/lazarus.git

I think that's the important detail. After all, Trev was saying how to use git from the command line, not how to navigate around a website.

Whatever my reservations about being force to use git, this is actually an advance over Subversion which did make it "challenging" to review tags etc. remotely. If OP is /completely/ unable to use git in this way he should say so before we go any further.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: How to use git
« Reply #6 on: November 22, 2021, 05:42:08 pm »
Thanks for the suggestions.
I can take the commands given and run on my Linux box for Lazarus.
But I have no understanding about how the actual URL was arrived at so could you please also give me the corresponding fpc URL?
I tried this but it resulted in some kind of login being required, which was not needed for lazarus:
Code: Pascal  [Select][+][-]
  1. git ls-remote https://gitlab.com/freepascal.org/fpc/fpc.git
  2. Username for 'https://gitlab.com':
  3. Password for 'https://gitlab.com':
  4. remote: HTTP Basic: Access denied
  5. fatal: Authentication failed for 'https://gitlab.com/freepascal.org/fpc/fpc.git/'

I need to document this exactly when I now embark into the post-SVN era for fpc/lazarus, otherwise I will have a guarantee to forget it until the next time I need to install again (I probably do 2-3 installs like this per year).

And to simplify things along with the descrition document I also usually write bash scripts where the commands are housed for a complete install from scratch, one for PC Linux and one for Raspberry Pi devices.

--
Bo Berglund
Sweden

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9855
  • Debugger - SynEdit - and more
    • wiki
Re: How to use git
« Reply #7 on: November 22, 2021, 05:44:45 pm »
Just browse the gitlab page to the fpc source repository page. Copy the url from the "clone" button.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: How to use git
« Reply #8 on: November 22, 2021, 05:55:38 pm »
Just browse the gitlab page to the fpc source repository page. Copy the url from the "clone" button.

I can confirm that taking the links you provided earlier and then following through as above generates a usable listing of tags etc.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: How to use git
« Reply #9 on: November 22, 2021, 05:58:17 pm »
Now I tried the follow-up command for lazarus in order to get the 2.0.12 sources but it did not result in anything I can use...

Code: Pascal  [Select][+][-]
  1. $ git init
  2. Initialized empty Git repository in /home/bosse/devel/lazarus/.git/
  3. $ git fetch --depth=1 https://gitlab.com/freepascal.org/lazarus/lazarus.git lazarus_2_0_12
  4. remote: Enumerating objects: 12468, done.
  5. remote: Counting objects: 100% (12468/12468), done.
  6. remote: Compressing objects: 100% (11149/11149), done.
  7. remote: Total 12468 (delta 2684), reused 7275 (delta 1168), pack-reused 0
  8. Receiving objects: 100% (12468/12468), 34.50 MiB | 8.11 MiB/s, done.
  9. Resolving deltas: 100% (2684/2684), done.
  10. From https://gitlab.com/freepascal.org/lazarus/lazarus
  11.  * tag               lazarus_2_0_12 -> FETCH_HEAD
  12.  
  13. $ git switch lazarus_2_0_12
  14. fatal: invalid reference: lazarus_2_0_12

There was no directory with source files created in any of these commands in the dir I was positioned...
The only additional dir created was the .git hidden dir. And it only contains some 35 KB of data...
Something here is obviously in error.
--
Bo Berglund
Sweden

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: How to use git
« Reply #10 on: November 22, 2021, 06:48:49 pm »
git init is only to use if you want a new repository of your own. https://git-scm.com/docs/git-init

If you want to work on a 'normal' git repository you have to use clone first (NOT init). After this you can switch to the branch or tag you want.

Earlier in the thread you have used the clone command and after this you can switch with 'git branch lazarus_2_0_12 origin/lazarus_2_0_12' and followed by a "git checkout lazarus_2_0_12"
regards
Andreas

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9855
  • Debugger - SynEdit - and more
    • wiki
Re: How to use git
« Reply #11 on: November 22, 2021, 06:49:33 pm »
A probably because I tried a branch.....

Code: Bash  [Select][+][-]
  1. git switch -c lazarus_2_0_12 FETCH_HEAD

should do (with tags, branches and commits).
THe "lazarus_2_0_12" you can freely name.

You can do that in your existing folder, if you still have it.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9855
  • Debugger - SynEdit - and more
    • wiki
Re: How to use git
« Reply #12 on: November 22, 2021, 06:54:08 pm »
git init is only to use if you want a new repository of your own. https://git-scm.com/docs/git-init

If you want to work on a 'normal' git repository you have to use clone first (NOT init). After this you can switch to the branch or tag you want.

Earlier in the thread you have used the clone command and after this you can switch with 'git branch lazarus_2_0_12 origin/lazarus_2_0_12' and followed by a "git checkout lazarus_2_0_12"

I intentionally did specify steps, without "clone".

init, then fetch => allows you to fetch any single commit.


It is possible to fetch as many individual commits (even from different repos) as you want. They all will go to FETCH_HEAD.

So then you must give them a branch/name of their own, before fetching the next.
That is done with:
  git switch -c MyName FETCH_HEAD

After that you can switch to it with just
  git switch  MyName


Note that branches fetched like this, to not have a remote to follow.
  git pull  / git remote update / git fetch
will NOT get any updates for them.


If you are happy with just having downloaded the commit (like an svn export), and do no longer need to interact with the remote, then you can delete the .git folder.


« Last Edit: November 22, 2021, 06:56:38 pm by Martin_fr »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: How to use git
« Reply #13 on: November 22, 2021, 11:19:06 pm »
1. $ git clone -b lazarus_2_0_12 https://gitlab.com/freepascal.org/lazarus/lazarus.git laz2012

2. $ git clone -b release_3_2_0 https://gitlab.com/freepascal.org/fpc/source.git fpc320

This only downloads the specified branch. Simples :)

So how do you find the tag names you used in the commands above?

If you go to the URLs I gave for each of Lazarus and FPC using a web browser, you can simply  use the dropdown box that will currently say "main" to see all the other branch names. However, given the "starter" branch names I provided, you could probably guess the rest for official releases.

dbannon

  • Hero Member
  • *****
  • Posts: 2791
    • tomboy-ng, a rewrite of the classic Tomboy
Re: How to use git
« Reply #14 on: November 23, 2021, 02:22:40 am »
Depending on your need, maybe you don't need to use git at all ?  gitlab will allow you to download a zip file of whatever branch/tag you nominate.  Its a reasonably quick 50meg download.  If you are not planning to generate pull requests or update daily, I suggest its a lot easier.

You just use the gitlab webpage, navigate to Lazarus, select the tag/branch you want from left hand side, click the download button, second rightmost button.  No knowledge of git required, no install of git required, no history.

Davo

 
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018