Basics of Git

Rachelpadworski
2 min readMar 30, 2021

Thanks to GitHub, we can push changes to our local projects and view those changes. We can revert back to a previous version, delete changes made, branch out of a main project, and more! GitHub is brilliant. I use it for all of my projects and you should too.

I wanted to list the basics of using git from your command line. I use VSCode — it’s my favorite editor.

  • git status — Shows if you have any changes that need to be pushed to GitHub.
  • git add . — Adds all changes. You could also select the specific files/changes you want to add.
  • git commit -m “ “ — Adds a message with that change. Should be in present tense (i.e. git commit -m “adds button styling”).
  • git push — Pushes the changes to the main/master project.

Here’s a great article on the basic git commands.

When I’m starting a new project, I tend to set up the template/basics locally first, then I initialize it in GitHub. Here’s how that works:

  • In GitHub, select the plus sign and “New repository.”
  • Name your new project. I named mine “my-new-repository.” I don’t add a description or anything else at this time because I can add it myself.
  • Click “Create repository.”
  • In the command line of your project (make sure you have cd’ed into your project directory) type “git init”, “git remote add origin” and the location of your project…mine is this: git@github.com:rachel-padworski/my-new-repository.git (so that full line would be “git remote add origin git remote add origin git@github.com:rachel-padworski/my-new-repository.git”) for me.
  • “git add .”
  • “git commit -m “initial commit””
  • “git push”
  • Then you’ll be able to view the code for your project on GitHub!

Happy coding!

To see how to start a React & Rails project using GitHub and your local environment, view this article.

--

--