Git is confusing. I am aware hot useful it is, but often I forget how to use it (especially if programming is not your day job). Hence I am documenting here how to use it ,especially when using with Visual Studio Code for Flutter.
I am a novice Git user, so I hope to update this page while learning how to fully use it.
Git Basics of the Basics
First, if you don't know what Git is in the first place, visit pages like this one - https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/
and there are lots more available over else where.
Git Basics
Git Directories
Keep in mind that there are three directories in git.
- Your Working Directory, essentially the folder where you are currently coding
- The Index folder, this is where you stage your code
- Finally the Head, this is where the code resides once you commit it
The Flow
Here is a basic flow when using git
- Create a Repository
- Make changes to your code
- Stage code (this is when you move your current code to the Index)
- Commit code (the code now is in the Head)
- Push code (Finally, this pushes your code to the remote repository)
simple.
Detailed Steps using VSCode/Flutter
For new Projects
- Create Flutter project
- Go to Source Control
- Click the plus sign (Initialize Repository)
- Select the project folder you just created
- Notice on the left pane, files are being put in to repository
- Hover on Changes, then click the plus sign (Stage All Changes)
- Click on the check sign (Commit)
- Go to GitHub
- Create a repository
- Copy your repository URL
- Go back to VSCode
- Open the Command Palette
- Execute Git: Add Remote
- Specify a name (e.g. origin)
- Enter your repository URL, then enter
- Now push your code! Click the three dotted icon, select Push
Top comments (0)