The right way to use GitHub


Table of Contents

This is a series of commands to effectively use GitHub in your work.

  • where testbranch replace with branch name
  • where pathname path of file that changed (from git status)

Creating and working in a feature branch

1. Create branch and checkout
$ git checkout -b testbranch origin/master

2. Push branch online
$ git push origin testbranch

3. Check branch you are in (you should see *testbranch)
$ git branch

4. Pull branch
$ git pull origin testbranch

**5. Make changes **

6. Commit changes
$ git status
$ git add . (if you have added new file)
$ git commit -m "made changes" pathname

7. Push changes
$ git push origin testbranch

8. Make pull request
go to GitHub console

9. Write details

10. Delete remote branch
$ git branch -a
$ git checkout master (make sure you are on another branch)
$ git push --delete origin testbranch

11. Delete local branch
$ git branch -D testbranch

12. Fetch branch remote
$ git remote update
$ git branch -r
$ git checkout -b testbranch origin/testbranch

13. Sync branch with master
$ git checkout testbranch
$ git merge origin/master or $ git rebase origin/master

14. Change the name of last commit
$ git commit --amend
To exit press ESC button and write :wq or :wq! and then Enter to close the unix file.