Ask 100 software developers what you need to know as a developer, and you'll get 100 different answers. Except for one thing: 99 of them will tell you to learn about Git.
Git and version control are universal nowadays. It's not hard, but it can be slow and confusing when you're a beginner. Let's alleviate that by having you work with the tool!
Today will be all about working with Git. The goal is to use the tool until it becomes more natural. The lab instructions will be vague on purpose. The aim is for you to sift through documentation and resources to find out what the next step is.
It's incredibly easy to have AI tell you what to do next if you get stuck. That defeats the purpose of this exercise. Relying on AI for help is like learning a new language by using Google Translate instead of following the exercise steps.
The learning is in the doing. If you don’t take the time to figure things out yourself, your long-term learning will suffer. IF you do end up completely stuck, ask in Slack or Dircord!
Make sure you have Git installed, together with VS-Code.
Throughout the lab, we will work in the terminal to run the Git commands.
-
Make a new repo on GitHub.com and clone it to your own computer. If it is your first time doing this, you might have to create an SSH-key and add it to GitHub
-
In your now local repo, open in up on VS-Code. From here, create a new file named
news.md, add a "Hello World" inside and commit that file with an appropriate commit message. -
Once you've committed the
news.mdfile, push your commit to the remote repository on GitHub.
-
In the news.md file, add anything interesting you've learned about recently. Once added, commit!
-
Create a new branch named
feature/update-news. Switch to this new branch. This is where you will make more changes to yournews.mdfile. -
In the
feature/update-newsbranch, add another paragraph in the news.md file (maybe link to a news article you've read?). Commit! -
Now, push this new branch to your GitHub repository. Then go to the Repo online and make sure it's there.
-
Online at GitHub, create a Pull Request (PR) from the
feature/update-newsbranch to the main branch. This will merge the changes from your new branch to the main one. -
Review the changes to make sure whoever did the changes did not do anything wrong and then, merge the pull request.
-
Now, go back to your local environment. Switch to the
mainbranch and pull. Your changes should now be available.
-
Make a change to
news.mdbut don't commit it. Stash these changes! -
Switch to another branch or create a new one. Here, make some different changes and commit them.
-
Now, go back to the previous branch (hint: git checkout -) and restore your stashed files.
Congratulations! You've just performed some very common Git tasks. From cloning a repository to making changes, committing them, working with branches, creating PRs, and using stash.
Remember, the more you practice, the more comfortable you'll become. And, just like any other skill, consistency is key. So, keep "gitting" at it!