Git & GitHub: verschil tussen versies
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) | Finally! It's 2022 and I'm ready for the 21st century: We're adopting Git - The most popular ''Distributed Version Control System'' (VCS) | ||
− | == Git clients == | + | == 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. | + | 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 == | ||
Regel 13: | Regel 13: | ||
* 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 | * 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. | * 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 [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> | ||
+ | |||
+ | == Clone the main branch == | ||
+ | |||
+ | How to download a clone of only the main branch? E.g.: A collection of bash files? | ||
== See also == | == See also == | ||
Regel 26: | Regel 59: | ||
* https://github.com | * https://github.com | ||
* https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token | * 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 |
Versie van 5 jan 2023 16:24
Finally! It's 2022 and I'm ready for the 21st century: We're adopting Git - The most popular Distributed Version Control System (VCS)
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
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 GitHub. 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
Clone the main branch
How to download a clone of only the main branch? E.g.: A collection of bash files?
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