GitHub
GitHub is a web-based platform that provides hosting of coding repositories. It offers a centralized location for people to store, manage, and allow collaboration on their code. It is especially useful for version control and project tracking. The following information is geared towards linking gluey annex repositories with GitHub, but can easily be used to link your home computer to a GitHub repository. This wiki page is being updated as the author learns how to use GitHub, so if you know a better, more efficient way to accomplish a task then by all means please do it that way (... and add an addendum to this page if you have a login).
The Setup
- Sign up for a GitHub account by going to the GitHub website and create a new account
- If you do not make your email address public you will have problems pushing your code later - Once you're logged in, click on the "+" sign at the top-right corner of the GitHub homepage and select "New repository" to create a new repository. Give your repository a name and provide a description.
- The repository name will be your folder name on gluey (see below)
- Repository description is optional
- Repository Setting:
- Private vs. Public
- License (optional) - MIT License is well known and least restrictive
- You can add a README file
- You can also rename the main branch (this must be done before the repository is created, changing the name will change all subsequent repositories that are made in the future)
- And more ...
- At the top-right of the GitHub website click on the pull-down and select "Settings"
- On the left select "Developer settings" located at the bottom
- Then on the left select "Personal access tokens"
- Select "Fine-grained tokens" or "Tokens (classic)", I did the prior one
- For the Fine-grained token you will need to select which permissions you'd like to allow (not sure about the classic token)
- Select a period for the token to be valid, upto 90 days maximum (I believe)
- Once complete it will provide you with the token you can copy, this will be used in place of your password later
- Log in to gluey using a VNC and navigate to the location in your annex where you'll be working
- You can do the same for your home computer, you'll just need to open a terminal or command prompt and navigate to the directory where you want to store your code
- Type the command:
git clone https://github.com/your-username/your-repository.git
- Make sure to replace "your-username" with your GitHub username and "your- repository" with the name of your repository - You will now need to login. Use your GitHub Username, but make sure to use the Personal Access Token you created earlier and NOT your GitHub password
- Confirm that the remote repository is correctly added, use the command:
git remote -v - If needed, you can link the local repository to the remote repository using:
git remote add origin <repository-url>
- Determine the name of the branch you want to switch to via:
git branch
- It will show all branches available and indicate your current branch with a * - Create a new branch using:
git branch new-branch-name - Switch to that branch and work in it via:
git checkout new-branch-name - The two steps above can be combined:
git checkout -b new-branch-name
- This will create and switch to the new branch in one step
git add folder-name
OR
git add .
If you want to add all new files and folders in the current directory
https://github.com/git-guides/git-add
git commit -m "Commit message"
Replace Commit message with a descriptive message summarizing the changes you made.
git push origin branch-name
Replace branch-name with the name of the branch you want to push to (e.g., main)
You will need to login with your Username and Personal Access Token