77 lines
2.1 KiB
Markdown
Executable File
77 lines
2.1 KiB
Markdown
Executable File
---
|
|
creation date: 2024-08-22
|
|
modification date: Thursday 22nd August 2024 11:56:21
|
|
tags:
|
|
---
|
|
# Preamble
|
|
### Notable Links
|
|
|
|
## What are we doing?
|
|
Learning how to use Github. This will probably be the easiest way to keep files synced between working at home and working on my laptop. This way, I can also just pull files down to really any machine and make things shareable. I also want to keep my neovim config up there in the cloud
|
|
|
|
## Why are we doing it?
|
|
For code based things, transferring to and from the server is annoying. Maybe Git is the answer.
|
|
## Who cares?
|
|
Me, for now.
|
|
|
|
# Learning to Use **Github**
|
|
## Preliminary Setup
|
|
Create a ssh key on the terminal if you don't have one:
|
|
```bash
|
|
ssh-keygen -t ed25519 -C "dane.sabo@pitt.edu"
|
|
```
|
|
Copy the contents of this key:
|
|
```bash
|
|
cat ~/.ssh/id_ed25519.pub
|
|
```
|
|
Notably, the public key is .pub. Do NOT copy the private key.
|
|
Upload this key to GitHub- go to settings>SSH and GPG keys>add the new key
|
|
Then add they key to the local SSH agent:
|
|
```bash
|
|
eval "$(ssh-agent -s)"
|
|
sshadd ~/.ssh/id_ed5519
|
|
```
|
|
|
|
## Using an existing repository
|
|
```bash
|
|
# Cloning a Repository
|
|
git clone git@github.com:danesabo/example_repo.git
|
|
|
|
#Staging and Committing Changes
|
|
git add . #adds all files
|
|
git commit -m "Commit message here!"
|
|
|
|
#Push the changes to GitHub
|
|
git push origin master #or main
|
|
```
|
|
|
|
## Starting a new repository
|
|
```bash
|
|
# Navigate to whatever folder repository is in
|
|
git init # initialize the repository
|
|
git add README.md # This is the top level long form description that'll be read in GitHub
|
|
git commit -m "first commit"
|
|
git branch -M master # some people use "main"
|
|
git remote add origin git@github.com:danesabo/repository.git
|
|
git push -u origin master
|
|
|
|
```
|
|
|
|
## Working with branches
|
|
```bash
|
|
#Create a new branch
|
|
git branch new-branch
|
|
|
|
#switch to that branch
|
|
git checkout new-branch
|
|
|
|
#or do both at once
|
|
git checkout -b new-branch
|
|
|
|
#or even if you're in a newer git version
|
|
git switch -c new-branch
|
|
|
|
#push the new branch back to remote
|
|
git push -u origin new-branch
|
|
#git push (set new pushes to new branch spec) (remote destination) (branch name)
|
|
``` |