Come on in padawan, start your open source journey with a hello-git. Git is a version control system that basically.....let's you have versions. It lets you click a snapshot of your code state and store it in a photo album - the history of your project. Basically no more of this...
New code doesn't work? Go back to old version
Office on fire? Take a snapshot of your code and upload......oh and leave the building after that
Deleted the entire prod database? Shhhhhh revert to old version. Yeah you get it
You need these things before you go to the next steps:
1. [Install git if you haven't](https://git-scm.com/download/win) (duhhhh)
2. Create a github account
And now we getting started for reals
Would you ever want someone unknown to change your code? Hard pass
So you gotta make your own copy of that code. How?? Just click on fork and follow some simple steps.....Aaaannddd you're done!
Just remember, your fork is called origin and where you forked from is called upstream
Time to embrace the keyboard.
Open your terminal in the folder you want the code. Run git clone https://github.com/<your username>/hello-git.git
cd hello-git
Set your username and email with git config --global user.name "YOUR_USERNAME" and git config --global user.email "YOUR_EMAIL"
I recommend keeping them the same as your github profile but you can do otherwise if you a lil adventurous.
Set the upstream with git remote add upstream https://github.com/c-d-a-o/hello-git.git
And check all links attached to your repo with git remote -v
I know it sounds useless right now but ALWAYS MAKE A NEW BRANCH FOR A NEW CHANGE
This will help you in the years to come. One branch only allows one PR (dunno what this is? we'll cover it). So always make a new one.
git branch newbranch to make the branch
git checkout newbranch to shift to new branch
Keep a descriptive name. Smth like feat: <your-name> works for this one. An example of well made branch names:
It's a gatekept secret in the tech world. Walking cats always write the best code. Brownie points for clean documentation.
......Or if you don't have a cat. Just write some code. Like we do (sm1 plz gift me a cat)
Now we wanna take a snapshot of what we wrote. But what files to include?
This is called staging. We stage the files we wanna include in the snapshot.
Simply use git add file.txt to add file.txt to the staging area
Want to stage all files? git add . is just for you
Wanna remove a file from staging area? git restore --staged file.txt saves the day
Now it's time to commit your code to history. Now you can revert shitty code. And others can blame you for shitty code. LITERALLY!
Decide on a good message to let others know what you changed. PLEASE make this message good and do others a favour. No one likes to be confused.
Just add the message to this: git commit -m "good message"
And you're done.....for now
Remember, all this change is in your own fork. Time to give it back to the OGs. We do this with a Pull Request (PR) which is basically a digital way to say "Hey! Just review this code and merge this into your repo"
First push the code to your remote fork using git push origin <branch-name>
Now open your fork on github. Just click on compare and pull request. Add a good description and submit. Done.
Now, wait for the endless list of improvements the maintainer sends which you'll forget to change sit back and give yourself a pat on the back for your first PR.
As a parting gift, we're giving you the only source you'll ever need for git. No problems. EVER AGAIN. Link
.
.
.
.
.
.
.
.
.
Yeah there's none. Keep building, keep learning. I learned this today making this:
It's never gonna end. You'll stumble along the way - it's a canon event. And then learn even more.
This is how we stay relevant. How we stop ChatGPT from taking our jobs. CDAO, GPT and StackOverflow are your friends in this journey.
Anyways