Skip to content

Latest commit

 

History

History
94 lines (47 loc) · 3.54 KB

git101.md

File metadata and controls

94 lines (47 loc) · 3.54 KB

Why git

git is the almighty source control software out there. If you want to colaborate with your peers, change code without being worried it won't work later or even contribute to people/company projects, than git is the way.

To get accostumate to git you just need to use it. It isn't one of those things that you can master right off the bat, so just keep pushing it and eventually you will find yourself confortable with it. So on this WS you will only get some basic commands you need to start using it.

Btw, git lives mostly on the command line! To install it you just need to write:

$ sudo apt install git

git clone

Clone is basically the copying a repository from other user and make you able to collaborate in it. To do it follow these steps: Find a project->click on "<>Code"-> Copy the https link

image

Then just do:

$ git clone *url*

Now you have access to this repository! If it is private you might need to set up the account, but that would be too long too post here so Google will have to help you :).

commit

When you make changes and want to record them so you can go back earlier, you use commit. This will save the changes in your local repository.

$ git commit

push

After committing the latest changes, you already have saved the changes in your local repository. But now you want to push them to the remote repository for everyone to access! That is what git push does.

When doing it, you might be told you need to stash your changes before or even pull the most recent changes on the remote repository, it is an headache!

$ git push

pull

Yeeeeah, you might not be the only one working on the same repository. Here is when git pull comes. It basically gets you the most recent changes on the remote repository!

$ git pull

Create your first PIO project with git

git init and VSCode

Sooooo, when you create a PIO project, it doesn't create a git repository for you, boring isn't it?? So what you need to do is git init on that same repository!

image

This will create a local git repository and as you are on VSCode you don't even need to use the terminal! Just follow this steps:

image

Click commit and clcik yes on the pop-up window. Then press Publish Branch and choose your repository name and how you want to save it!

PS: you need to connect your github account with VSCode

image

Congratulations you have created your first git project!!

But now, how to clone a repository using PIO??

git clone and PIO config

First pick the commit link as taught before. Then find a place where you want to place your project. I recommend the PIO Projects folder.

On the command line do:

/mnt/c/Users/User/Documents/PlatformIO/Projects$ git clone *url*

After the project exist on your computer, go to VSCode -> PIO Home -> Click Open Project. In there select the folder the project is located!

image

Should be working and Visual Studio should already be configured to use with git!

Main Menu | Next