This content originally appeared on DEV Community and was authored by Levani (Leo)
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>
2) Get all branches:
git fetch --all
3) Move to the dev branch:
git checkout <dev>
4) Create and move to a new branch:
git checkout -b <branch_name>
The branch name must be the task name.
5) Add changes or Undo changes:
Add changes
git add <file_name>
or
git add *
Undo changes to certain files if they were not added to git:
git checkout <file_name>
Removes an object from git repository, but not file:
git rm -r --cached <file_name>
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'
7) Push the new branch alongside the one from which you created it:
git push --set-upstream origin <branch_name>
8) Pull changes from a specific remote repository:
git pull origin <branch_name>
P.S. Follow the steps outlined above, and your project repository will remain secure.
This content originally appeared on DEV Community and was authored by Levani (Leo)