Using Git: The basic stuff

Dexter Moss
3 min readApr 1, 2022


GitHub logo

After completing five group projects for my engineering boot camp, I decided to write a quick article on how to use git commands for a better workflow with your collaborators. In this article I will give quick steps to pulling a repository, working on your separate branch, and pushing back to the main repository to merge with the code. I will also give a GitHub extension suggestion that could help tremendously when in doubt.

How to clone the original repository?

First, visit the repository on GitHub and copy the URL. Then, in your terminal run the command:

🔘 git status — this will print to the console your working directory and ensure that you are on a clean branch before cloning the repository to your machine.

Next, run the command:

🔘 git clone [paste the repository link here minus the backets] — this will clone the repository to your machine and allow you to push and pull from the main branch.

How to work on your separate branch?

Before you make any changes to the repo and start to code, create a se[perate branch to keep all of your changes separate from the main branch. This tip is probably the most severe step in keeping repositories clean and avoiding merge conflicts. If you do not do this step you run the risk of merging code that conflicts with another contributor on the project and could overwrite any pertinent code to the project. To create your separate branch run the command:

🔘 git checkout -b my-name (replacing my-name with whatever name you want, I suggest using names that are helpful to remember what you are doing on the branch, such as button-component or search)

If you want to switch back to the main branch (or any branch) and pull updated code into your machine, use the command:

🔘 git checkout my-name (replacing my-name with the branch you want to switch to) and then,

🔘 git pull (this command will also print a list of all branches that are associated with the branch that you pull from)

How to save your work and push changes to the main branch?

Run this command to check which branch you are on:

🔘 git status

Ensure that you are on your branch, if not, run this command:

🔘 git checkout main (replacing main with the branch name you want to switch to)

From this branch, add, commit and push your changes

🔘 git add . (stages changes)

🔘 git commit -m “messages about the commit” (commit changes)

🔘 git push (push changes to your branch)

Then switch to the main branch and merge your branch with the commands:

🔘 git checkout main (replacing main with the branch name you want to switch to)

🔘 git merge my-branch (replacing my-branch with the branch name you want to merge)

Once the merge is complete, wait for the merge to be accepted and then delete the branch. Either manually on GitHub or run the command:

🔘 git push origin — — delete my-branch-name (replacing my-branch- with the branch name you want to switch to)


Merge conflicts are common as well as traversing branches looking for the content you want.

If you hit any conflicts check out this article!

I suggest using GitLens inVSCode for a great visual on source control, branch status and commit history.

I also suggest setting your Visual StudioCode SSH key to link with GitHub for easy push/fetch/to pull requests.



Dexter Moss

| MBA | Healer | FullStack Engineer | Social Butterfly