DEV Community

Levani (Leo)
Levani (Leo)

Posted on

GIT guide for juniors

✨ Introductions

This guide is created for beginners to ensure the development and production branches are secure.

🚀 Let's start

1) Get the repository:

First, you need to choose which type of connection to the GitHub repository suits you best.

  • SSH: Use this if you have it configured locally and the public key added in the (ssh) settings section on the GitHub website.

  • HTTPS: The basic option using your username and password.

git clone <repository_url>
Enter fullscreen mode Exit fullscreen mode

2) Get all branches:

git fetch --all
Enter fullscreen mode Exit fullscreen mode

3) Move to the dev branch:

git checkout <dev>
Enter fullscreen mode Exit fullscreen mode

4) Create and move to a new branch:

git checkout -b <branch_name>
Enter fullscreen mode Exit fullscreen mode

⚡ The branch name must be the task name.

5) Add changes or Undo changes:

Add changes

git add <file_name>
Enter fullscreen mode Exit fullscreen mode

or

git add *
Enter fullscreen mode Exit fullscreen mode

Undo changes to certain files if they were not added to git:

git checkout <file_name>
Enter fullscreen mode Exit fullscreen mode

Removes an object from git repository, but not file:

git rm -r --cached <file_name>
Enter fullscreen mode Exit fullscreen mode

⚡ Make sure that files not allowed in the remote repository have not been added.

  • For example: .env, cache files and temporary files.

6) Apply changes:

git commit -m 'branch_name: list of changes'
Enter fullscreen mode Exit fullscreen mode

7) Push the new branch alongside the one from which you created it:

git push --set-upstream origin <branch_name>
Enter fullscreen mode Exit fullscreen mode

8) Pull changes from a specific remote repository:

git pull origin <branch_name>
Enter fullscreen mode Exit fullscreen mode

P.S. Follow the steps outlined above, and your project repository will remain secure.

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more