Convince someone's thing to depend on your thing, and then push a change that breaks their thing.
You're at Hack the Tunnels. Your friend wants to impress their crush somehow.
We need a way to share the cool thing we made with them. Let's turn that into a repository.
Navigate back to your VS Code Terminal and do the following.
Now let's make a commit.
You should see.
Let's tell git to track changes to the file we want to commit.
You should see:
Great, now we need to actually send the link to this somehow. We can use GitHub for this.
It will host a remote version of the repository that our friend can download.
We don't want to create a new repository, but rather push an existing one.
Leave the path as is, and hit enter.
Leave the Repository name as is, and hit enter.
Select your personal account as the owner, and hit enter.
You can provide it any description you like. Since we're in a hurry, we'll leave it blank.
Leave it as public.
Hit enter to add the remote.
Hit enter, leave it as origin.
Hit enter, leave it as origin.
At this point you're done :)
Navigate to the url in the final line to see your git repository hosted on GitHub.
Nice, now your friend can get your cool stuff with:
The format for what comes after `gh repo clone` is the same as shown on the top left of your GitHub repo.
Your friend calls you over...
UH OH
Your crush is there too. We need to impress them somehow.
Your friend has the same code as you and your crush has probably already seen it.
Your cool thing must not look the same as theirs. You need to quickly make changes and save them to a different version of the file.
Let's see the branch we're currently on.
If you see (END)
, press q to quit.
Make a new branch called my-branch
.
Check the branch you're on again.
Make some changes to your file, run them to check that they work and commit them.
That didn't seem to work. This is because git doesn't automatically mark your changes to be committed.
Let's stage them.
Now try again.
Nice.
Let's change the echo
to something cooler, like figlet
, and RGB it as well.
Uh oh, do we have figlet
installed? Let's check.
Looks like we don't. Let's install it and try again.
It works! We can both stage and commit it in one go with -am
See if everything worked and what the current state of our repository is.
Let's push our changes to remote.
You will see:
This is because GitHub (upstream) doesn't have the main
branch that we created locally.
So we do:
Now you can find your branch on GitHub.
Let's see what the file looked like before on the other branch.
You'll see file.sh
change to the version it was before.
Back to my-branch
:
There are many more git commands, and this barely scratches the surface.
What will be the outcome of your adventure? It's the one you create here in present :)
To be continued...