paint-brush
Basic Git Workflow For Beginner Software Developersby@highcenbug
1,876 reads
1,876 reads

Basic Git Workflow For Beginner Software Developers

by Vicente Antonio G. ReyesOctober 16th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A good practice is to name the branch with the focus of your edit. Make it a habit to do small changes so it's easy to go back if you mess up. Git will compain because GitHub doesn't know about your new branch. If you want to delete a branch, go to the main branch then delete our branch from there. This is what I learned in an hour, with an example of the main repository from a mentor from a Git mentor. The tips to use Git are: create a new branch, checkout, add, commit and push to remote repository.

Company Mentioned

Mention Thumbnail
featured image - Basic Git Workflow For Beginner Software Developers
Vicente Antonio G. Reyes HackerNoon profile picture

Make it a habit to run

git status
before doing anything on a repository. I just learned this today and wanted to write it down to make it stick on my mind - or get familiar with it.

1. To create a new branch

Execute

git branch <name_of_branch>
. A good practice is to name the branch with the focus of your edit.

Ex:

git branch markdown

2. Checkout a branch

Run

git checkout <name_of_branch>
to work on your branch. Make it a habit to do small changes so it's easy to go back if you mess up.

Once done with your changes, you want to add all changes, commit to your changes and push it to your dev repository.

a) Now you run

git status
to see the changes on your repository.

b) Then run

git add <filename>
or you can do
git add -A
to add all the changes instead.

3. Create a commit

Commit your changes by running

git commit -m "Your message"

4. Push to remote

Finally, you push your commit by running

git push
. Git will compain because GitHub doesn't know about your new branch. So run
git push --set-upstream origin <branch_name>

If you want to delete a branch. We would go to the main branch then delete our branch from there.

a) To go to the main branch, run

git checkout <main_branch>

b) Once in the main branch, run

git branch -d <name_of_branch>

This is what I learned in an hour, with an example of the main repository from a mentor.