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
. A good practice is to name the branch with the focus of your edit.
git branch markdown
2. Checkout a 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.
to see the changes on your repository.
or you can do
git add -A
to add all the changes instead.
3. Create a commit
git commit -m "Your message"
4. Push to remote
. Git will compain because GitHub doesn’t know about your new branch. So run
git push --set-upstream origin
If you want to delete a branch. We would go to the main branch then delete our branch from there.
git branch -d
This is what I learned in an hour, with an example of the main repository from a mentor.