Jake Peterson

May 9, 2021

2 min read

Git Commands You Need To Know

Entering into Flatiron’s immersive software engineering bootcamp, I had not quite finished all the pre-work leading up to the first day. Unfortunately for me, one of the last few modules that I hadn’t quite got to yet covered some basic functionality regarding GitHub. To my dismay, the lab we did the very first day was over creating repositories and branches and merging with other students. Today I’ll be covering some key Git commands so that hopefully you don’t ever feel the same overwhelming sense of confusion and fear that I felt that day.

Git init: Initializes a git repository for your current or existing project.

Apply: Type git init from the root of you project directory

Git status: This allows you to see all the files that have been updated from your last commit.

Apply: Type git status in your directory

Git clone: Allows you to copy source code from a remote repository and save it to your computer.

Apply: Type git clone <repository-url-goes-here>

Git add: No code will be changed in the next commit unless you first add it to the staging area.

Apply: Type git add .

Git commit: This is very important and commonly used after completing a new feature or task on your project. It saves your code locally and you can also leave a message.

Apply: Type git commit -m “finished sign in feature”

Git push: Uploads your commits to the remote repository.

Apply: If branch is new type git push -u origin <branch_name>, otherwise type git push <branch_name>

Git pull: Allows you to get updates from the remote repository, which is just a combination of git fetch and git merge.

Apply: Type git pull <remote>

Git checkout: Allows you to switch to a different branch, branches allow multiple developers to work on the same project simultaneously.

Apply: Type git checkout <branch_name>, or if you want to create a branch and switch to it at the same time then git checkout -b <branch_name>

Git merge: Allows you to merge two branches together.

Apply: First switch to the branch you want your code merged in, then type git merge <other_branch_name>

These commands are all very important and commonly used, if you’d like to see more git commands i’ll link to some down below.