What is Git?
Created in April of 2005 by Linus Torvalds, famous creator of Linux, Git is a version control system. It allows you to see changes, called commits, to a repository. Each commit can build on top of the other, creating a chain of edits. Each edit can be tracked to a user.
GitHub
The most popular service for hosting Git repositories is GitHub, which is ironically closed-source. However, GitLab is a strong open-source alternative to GitHub.
Authenticating to GitHub
An easy way to authenticate Git is through GitHub Desktop. I was surprised to see that GitHub Desktop wasn't available on Linux. However, GitHub CLI is.
You can start authentication by running the following command for GitHub CLI:
gh auth login
Then, you can run standard commands like git commit to commit your code, and git push to push your code to the server.
There's also a useful feature in Git called branches. With branches, you don't always have to work on the default 'master' branch. You can create separate branches for staging, testing and experimentation.
The standard way to do this with Git is:
git branch <branchname>
…where <branchname> is the name of your branch.
I have published this site's source code to GitHub. If you'd like to view it, you can visit the public GitHub repository. Here's the list of commands I've used to publish it.
First, I initialized the Git metadata in the folder with the following command:
git init
Then, if you run the following:
git ls-files
… you will see it's blank, so we will fix that by adding our files to the commit:
git add --all
Then, we will commit our changes to the log.
git commit -m "First release of website"
Next, I add the remote origin. Note that to push to the origin, you must be authenticated, but I had already authenticated through GitHub CLI earlier.
git remote add origin https://github.com/cheapsk9/ButlerWebsite.git
And finally, we push our commits to the repository. And we're done!
git push --all origin