How To Use the GIT Command Line for Standard GIT Working Flow
GIT Standard Working Flow
- Receiving issues or new feature
- Switch to master branch: git checkout master
- Get latest code for master branch: git pull
- Create a new branch for working(it's just local branch): git checkout -b mac_20170111_feature_changetablename
- Begin working
- First commit
- Add, Edit, or change some things on the source code
- 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
- Add, Edit, or change some things on the source code
- 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
- Add, Edit or change some things on the source code
- 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
- Prepare For Pulling Request
- Rebase Commit (Collect and merge all commits on the current branch to one commit)
- Backup your branch(MAKE SURE YOU ARE AT YOUR BRANCH): git checkout -b <your_branch_name_BAK>
- Count commit on branch: Goto bitbucket and count
- For the example above we have 3 commits. so we will use git rebase -i HEAD~3 (Squash commit screen will show after execute)
- 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
- 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
- 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
- Admin will review your code if okay they will merge if not you must be fixed the comment then do all steps again.
- Finished
GoDevStack.com
Post a Comment
Thank for leaving message