Git & GitHub: verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 1: Regel 1:
Finally! It's 2022 and I'm ready for the 21st century: We're adopting ''Git'' - The most popular ''Distributed Version Control System'' (VCS), in combination with ''GitHub''.
+
Juhu! It's 2023 and I'm ready for the 21st century: We're adopting ''Git'' - The most popular ''Distributed Version Control System'' (''VCS''), in combination with ''GitHub'' (for storing the actual sourcecode).
 +
 
 +
== Installing Git ==
 +
 
 +
''Git'' is the software. It's basically a bunch of CLI commands that you install on the computers where you want to use it.
 +
 
 +
Installation:
 +
 
 +
<pre>
 +
sudo apt install git
 +
</pre>
  
 
== Git clients - Sublime Merge ==
 
== Git clients - Sublime Merge ==
Regel 7: Regel 17:
 
== GitHub ==
 
== GitHub ==
  
In practice, you'll probably spend more time at the website of the ''Git repository'' of choice, than of the site of ''Git'' itself. We use ''[https://github.com/ GitHub]''. You need a personal GitHub account and you somehow need access to personal repositories, or those of an ''organisation''
+
''[https://github.com/ GitHub]'' is an online storage service for use with ''Git''. As a comparison:
 +
 
 +
* ''Git'' is similar to Dropbox
 +
* ''GitHub'' similar to the Amazon S3 storage that Dropbox uses.
 +
 
 +
You need a personal GitHub account and you somehow need access to personal repositories, or those of an ''organisation''.
  
 
== Personal Access Token ==
 
== Personal Access Token ==

Versie van 5 jan 2023 17:40

Juhu! It's 2023 and I'm ready for the 21st century: We're adopting Git - The most popular Distributed Version Control System (VCS), in combination with GitHub (for storing the actual sourcecode).

Installing Git

Git is the software. It's basically a bunch of CLI commands that you install on the computers where you want to use it.

Installation:

sudo apt install git

Git clients - Sublime Merge

Interacting with repositories like GitHub, SVN or Bitbucket can be done using the command line, but it's more common to use a graphical Git client for this. One of these is Sublime Merge. Since Sublime Text is my default editor, I think I'll try Sublime Merge. See Sublime Merge for details, but changes are, that the main stuff is included in this article

GitHub

GitHub is an online storage service for use with Git. As a comparison:

  • Git is similar to Dropbox
  • GitHub similar to the Amazon S3 storage that Dropbox uses.

You need a personal GitHub account and you somehow need access to personal repositories, or those of an organisation.

Personal Access Token

  • A Github Personal Access Token is an alternative for a password, used for replicating through the API. Sublime Merge needs them. You can do so here: https://github.com/settings/tokens
  • Cloning a repository with Sublime Merge: I had to provide both my usual GitHub login name and the token.

Clone a repository

When you clone a repository, you get a copy of all versions of all files - Not just the main branch. See [1] for details.

On the GitHub site, see Organisation » Code » Local for details.

Sublime Merge

  • You can only use the HTTPS variant, not SSH
  • Create a personal access token (see above)
  • Sublime Merge » File » Clone repository

Command line

  • GitHub » Profile » Settings » SSH and GPG keys: Upload the computer's public key
  • git clone git@github.com:project_name/reponame.git

Remove a clone

[2]:

From within the directory that holds the .git file:

git gc --prune=all
cd ..
rm -rf reponame

BTW: As far as I can tell, GitHub doesn't keep track of where repositories have been cloned - I can clone & destroy them as often as I want (for practicing purposes) without creating weird meta data.

Clone the main branch

How to download a clone of a specific branch, like the main branch? E.g.: A collection of bash files?

Or am I asking the wrong question? I actually want to deploy the stuff that's stored on GitHub (although that's the wrong term) → See below

Deploy (?)

How to deploy, deploy a codebase, publish, release or use the stuff that's in GitHub?

Specifically: I want the script files in repository devliegendebrigade/scripts (or whatever) to magically appear in /usr/local/bin on servers, and in Dropbox/Overhead/Scripts on my laptop (or maybe I want to change that also to /usr/local/bin, now that I don't need Dropbox as backup for these).

  • For starters: Deploy seems the wrong term: It only leads to pages about GitHub Pages and that's not what I mean - Or maybe it's not the wrong name: [3]?
  • Maybe has to do with some two-step procedure including staging?
  • Related to the term workflow?

See also

Sources