Guide for a Beginner to GIT

Olga NedelcuOlga Nedelcu
2 min read

“Know how to learn. Then, want to learn.”- Katherine Johnson

If you are new to GitHub or working in a team using Git you probably will have to know your environment 😉

In this guide, we are going through some of the very basics of Git on VScode or any IDE 🙌

Git Workflow with package.json

1. Setting Up the Environment:

Before diving into Git commands, ensure you have Node.js and Git installed on your machine.

Running command: node –-version

(the result of that command should be a version of the node that we are currently having in our machine if not go ahead and install it from here)

2. Initial Setup:

Clone the repository to your local machine:

  • git clone <repository-url>

  • cd <repository-directory> / cd is used to move within directories or folders

3. Installing Dependencies:

Use npm to install all dependencies listed in the package.json file:

  • npm install

This command will create a node_modules directory containing all dependencies required by the project.

4. Adding Changes:

After making changes to your project, stage them for commit using:

  • git add .

Or

  • git add “file”

This command stages all modified and new files for the next commit.

5. Committing Changes:

Commit your staged changes with a descriptive message:

  • git commit -m “Your descriptive message here”

Ensure your commit message clearly describes the changes made in this commit.

6. Pushing Changes:

Push your committed changes to the remote repository’s main branch:

  • git push

This command updates the remote repository with your local changes.

7. Working with Branches:

If you need to work on a new feature or bug fix, create a new branch:

  • git checkout -b <new-branch-name>

Make your changes, stage them with git add, commit, and push as usual.

8. Updating from Main Branch:

Periodically, pull changes from the main branch to keep your local branch up to date:

  • git pull origin main

This command fetches changes from the remote main branch and merges them into your local branch.

9. Checking Status:

To check the status of your local repository, including changes not yet staged for commit or changes in the remote repository:

  • git status

This command provides information about the current state of your repository.

Commit your work as often as possible so others know what you are working on at the moment and we ensure working on the latest version of the project.

0
Subscribe to my newsletter

Read articles from Olga Nedelcu directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Olga Nedelcu
Olga Nedelcu

I'm a community-minded engineer based in Berlin, originally from Romania, and I grew up in sunny Spain. I combine the best of both communication and technical skills, with experience in both the engineering world and the business side of things. I'm proficient in a wide range of technologies like JavaScript, React.js, Redux, TypeScript, Node.js, HTML/CSS, Styled Components, SASS, and REST APIs. I love going beyond just writing code by sharing knowledge with my team through Communities of Practice (COPs), Employee Resource Groups (ERGs), and detailed technical documentation. My main interests are in frontend frameworks, web standards, accessibility (A11y), and Clean Code. My passion for programming started in high school when I built my first website. Since 2019, I've been working as a professional software developer, thriving in agile and iterative environments. Nearly five years later, I'm still excited to dive into code and collaborate with my colleagues. I'm very open and friendly, good at turning technical concepts into easy-to-understand information for everyone.