DEV Community

kenjmoj
kenjmoj

Posted on • Edited on

Using Git - Steps using with Visual Studio Code / Flutter

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

  1. Create a Repository
  2. Make changes to your code
  3. Stage code (this is when you move your current code to the Index)
  4. Commit code (the code now is in the Head)
  5. Push code (Finally, this pushes your code to the remote repository)

simple.

Detailed Steps using VSCode/Flutter

For new Projects

  1. Create Flutter project
  2. Go to Source Control
  3. Click the plus sign (Initialize Repository)
  4. Select the project folder you just created
  5. Notice on the left pane, files are being put in to repository
  6. Hover on Changes, then click the plus sign (Stage All Changes)
  7. Click on the check sign (Commit)
  8. Go to GitHub
  9. Create a repository
  10. Copy your repository URL
  11. Go back to VSCode
  12. Open the Command Palette
  13. Execute Git: Add Remote
  14. Specify a name (e.g. origin)
  15. Enter your repository URL, then enter
  16. Now push your code! Click the three dotted icon, select Push

Top comments (0)