Bitbucket - Git Short Note
Jira item
Create branch
Select repo
Git clone repo (clone repo to the local)
git pull (update local tree from the remote tree)
git checkout SSAT-3006-unit-test-add-unit-test-to-su
Check current branch
Open git bash
git branch
Git bash
git bash is a git commandline
Git GUI
Stage Ctrl + T
Unstage Ctrl + U
Sign off
Commit (to the local)
Push (to the remote)
Pull request
Commit and push to Jira branch
git pull origin develop (this step is to synch local branch with remote develop branch)
Resolve any merge conflicts
Stage, sign off, commit and push
Goto Jira item
Click Create pull request
Create a pull request from the current Branch to develop
Assign reviewer
Switch to another branch
git switch <branch>
git checkout <branch>
Resolve Merge conflict
Correct the conflict and compile the project
Stage, sign off, commit and push
Read more https://support.atlassian.com/bitbucket-cloud/docs/resolve-merge-conflicts/
Git stash and pop
git stash can be used for following
Save files to a shelve then when need to change to another branch, because Git does not allow to change branches when new modifications are in the codebase (uncommitted codebase)
Do the work in new branch commit them
Then git switch <branch> to the old branch
Then git stash pop to get back stashed codebase
git stash can be used to put unwanted codebase to a shelf
during a merge conflict
Master branch
Release branch
Develop branch
Development branch
Master bit bucket best practices
- Create and work on small tasks so chances for impactful merge conflicts are lower.
- Sync up your feature branch frequently.
- Commit to a local end of the work, every day
- git pull develop before start work on every day
- Merge your feature branches as soon as possible. If they’re done, don’t let them hang in there.
- Do not branch too deeply. You will be increasing the time to execute each merge and resolve potential conflicts. Means, avoid a situation like this:
- Structure your branch tree so you minimize the chances of overlapping sibling branches. You should aim to merge along the hierarchy; i.e, merge children into parent instead of 2 sibling branches.
- Be aware that the more work is planned to be parallelized the more chances to have merge conflicts.
- If merge conflicts are unavoidable, plan some time ahead to make sure you address them and their potential side-effects properly.


No comments:
Post a Comment