Git & GitHub: verschil tussen versies
(21 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 1: | Regel 1: | ||
− | + | 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). | |
− | == Git | + | == Installing Git == |
− | 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 | + | ''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 == | ||
+ | |||
+ | 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 == | ||
+ | |||
+ | ''[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''. | ||
+ | |||
+ | == Clone a repository == | ||
+ | |||
+ | When you ''clone a repository'', you get a copy of all versions of all files - Not just the ''main branch''. See [https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository] 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 | ||
+ | * <code>git clone git@github.com:project_name/reponame.git</code> | ||
+ | |||
+ | == Remove a clone == | ||
+ | |||
+ | [https://stackoverflow.com/questions/43115197/how-to-delete-a-single-git-repository-clone-without-the-rm-rf-sledgehammer]: | ||
+ | |||
+ | From within the directory that holds the <code>.git</code> file: | ||
+ | |||
+ | <pre> | ||
+ | git gc --prune=all | ||
+ | cd .. | ||
+ | rm -rf reponame | ||
+ | </pre> | ||
+ | |||
+ | 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 | ||
+ | |||
+ | == Push == | ||
+ | |||
+ | * Think of ''push'' or ''git push'' as ''publish'' or ''update'': Update the remote branch with local commits | ||
+ | * It seems you do this at the GitHub repository page, not in the local client (although I guess that would be equally possible). | ||
+ | |||
+ | Sources: | ||
+ | |||
+ | * https://github.com/git-guides/git-push | ||
+ | * https://stackoverflow.com/questions/26005031/what-does-git-push-do-exactly | ||
+ | |||
+ | == Deploy == | ||
+ | |||
+ | How to ''deploy'' a branch? | ||
+ | |||
+ | Specifically: I want the script files in repository ''devliegendebrigade/scripts'' (or whatever) to magically appear in <code>/usr/local/bin</code> on servers, and in <code>Dropbox/Overhead/Scripts</code> on my laptop (or maybe I want to change that also to <code>/usr/local/bin</code>, now that I don't need Dropbox as backup for these): | ||
+ | |||
+ | * GitHub » Actions | ||
+ | * Copy script: <code>scripts / .github / workflows / copy.yml</code>: A yaml script | ||
== See also == | == See also == | ||
Regel 12: | Regel 87: | ||
== Sources == | == Sources == | ||
− | * https://linuxhint.com/best_git_gui_clients_ubuntu/ | + | * https://git-scm.com/ - Official Git home page |
+ | * https://linuxhint.com/best_git_gui_clients_ubuntu | ||
+ | * https://git-scm.com/download/gui/linux | ||
+ | * https://github.com | ||
+ | * https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token | ||
+ | * https://en.wikipedia.org/wiki/GitHub | ||
+ | * https://en.wikipedia.org/wiki/Git | ||
+ | * https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository | ||
+ | * https://stackoverflow.com/questions/43115197/how-to-delete-a-single-git-repository-clone-without-the-rm-rf-sledgehammer | ||
+ | * https://youtu.be/0iuqXh0oojo - CodeOps Show: GIT: Merging and Workflow | ||
+ | * https://www.youtube.com/playlist?list=PLjQo0sojbbxVHcVN4h9DMu6U6spKk21uP - CodeOps Show: Git & GitHub playlist | ||
+ | * https://en.wikipedia.org/wiki/YAML |
Huidige versie van 9 apr 2023 om 20:32
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.
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
Push
- Think of push or git push as publish or update: Update the remote branch with local commits
- It seems you do this at the GitHub repository page, not in the local client (although I guess that would be equally possible).
Sources:
- https://github.com/git-guides/git-push
- https://stackoverflow.com/questions/26005031/what-does-git-push-do-exactly
Deploy
How to deploy a branch?
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):
- GitHub » Actions
- Copy script:
scripts / .github / workflows / copy.yml
: A yaml script
See also
Sources
- https://git-scm.com/ - Official Git home page
- https://linuxhint.com/best_git_gui_clients_ubuntu
- https://git-scm.com/download/gui/linux
- https://github.com
- https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
- https://en.wikipedia.org/wiki/GitHub
- https://en.wikipedia.org/wiki/Git
- https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository
- https://stackoverflow.com/questions/43115197/how-to-delete-a-single-git-repository-clone-without-the-rm-rf-sledgehammer
- https://youtu.be/0iuqXh0oojo - CodeOps Show: GIT: Merging and Workflow
- https://www.youtube.com/playlist?list=PLjQo0sojbbxVHcVN4h9DMu6U6spKk21uP - CodeOps Show: Git & GitHub playlist
- https://en.wikipedia.org/wiki/YAML