How To Use the GIT Command Line for Standard GIT Working Flow

 How To Use the GIT Command Line for Standard GIT Working Flow

How To Use the GIT Command Line for Standard GIT Working Flow


GIT Standard Working Flow

  1. Receiving issues or new feature
  2. Switch to master branch: git checkout master
  3. Get latest code for master branch: git pull
  4. Create a new branch for working(it's just local branch): git checkout -b mac_20170111_feature_changetablename
  5. Begin working
    • First commit
      1. Add, Edit, or change some things on the source code
      2. Begin Commit your changes
        • Over-viewing you're changed: git status
        • Add files changed to your commit: git add <some-file><folder> <.> or git add -A (A must be uppercase)
        • Commit your change: git commit -am "your comment1"
        • Push all commit to server: git push -f origin your_branch_name_here
    • Second commit
      1. Add, Edit, or change some things on the source code
      2. Begin Commit your changes
        • Over-viewing you're changed: git status
        • Add files changed to your commit: git add <some-file><folder> <.> or git add -A (A must be uppercase)
        • Commit your change: git commit -am "your comment2"
        • Push all commit to server: git push -f origin your_branch_name_here
    • Third commit
      1. Add, Edit or change some things on the source code
      2. Begin Commit your changes
        • Over-viewing you're changed: git status
        • Add files changed to your commit: git add <some-file><folder> <.> or git add -A (A must be uppercase)
        • Commit your change: git commit -am "your comment3"
        • Push all commit to server: git push -f origin your_branch_name_here
  6. Prepare For Pulling Request
    • Rebase Commit (Collect and merge all commits on the current branch to one commit)
      1. Backup your branch(MAKE SURE YOU ARE AT YOUR BRANCH): git checkout -b <your_branch_name_BAK>
      2. Count commit on branch: Goto bitbucket and count
      3. For the example above we have 3 commits. so we will use git rebase -i HEAD~3 (Squash commit screen will show after execute)
      4. Squash commit(Change all pick word to squash EXCEPT FIRST COMMIT that means squash last 2 commit to first commit)
        • Original:
          • pick 01d1124 your comment1
          • pick 6340aaa your comment2
          • pick ebfd367 your comment3
        • Change to:
          • pick 01d1124 your comment1
          • squash 6340aaa your comment2
          • squash ebfd367 your comment3
      5. Push to server: git push -f origin <your branch>
    • Rebase branch (Get the latest code from master(main branch) then merge code from master to current branch)
      • Backup your branch( MAKE SURE YOU ARE AT YOUR BRANCH): git checkout -b <your_branch_name_BAK>
      • Switch to the main branch: git checkout master
      • Get latest code for master: git pull
      • Switch again your branch: git checkout your_branch
      • Merge code from master to your branch: git rebase master
        • This case is only for conflict
          • git mergetool (screen resolve conflict will show you pick your code and resolve then save and close window)
          • Navigate to folder solution explorer find and delete all files with extension .ori .ori
          • git add .
          • git rebase continue
          • ....repeat to step git merge tool again until resolving all conflict
      • push to the server(now your code is latest with the master you can create pull request): git push origin your_branch_name_here
  7. Create Pull Request(Pull request is requested Admin review and merge your code to master branch)
    • goto bitbutket.org and login
    • Click Pull Request
    • Create new pull
    • Choose your branch and Branch that you want to merge
    • Input comment and click create.
    • Done
  8. Admin will review your code if okay they will merge if not you must be fixed the comment then do all steps again.
  9. Finished

GoDevStack.com

Post a Comment

Thank for leaving message

Previous Post Next Post
managed wordpress hosting
managed wordpress hosting