This is the second phase of my current project. After the Beta version of the project, I upgraded and shift the whole project into DevOps workflow. Git, is most essential part of the version control. So in this post, I will shsare some tips that I have encountered
Git Branching Models
There should be at least two models:
Dev branch is the front line defensing bugs. This branch
will proceed first round of testing.
Production branch is used for release the stable version of the software. Still this branch will
go through all possible tests and report bugs.
Protect master branch
In case the abuse of master branch, or any dangerous action to the release branch, it is better to restricts the access to master branch. when the feature https://stackoverflow.com/questions/38864405/how-to-restrict-access-to-master-branch-on-git
Create/ feature branch
git pull before your any actions
git pull git checkout -b new_branch current_branch
delete finished branch locally
git branch -D wanted_to_delete
Retrieve committed code
you have committed code / added all the code, but forget to push to the remote repo. After had checked out to another branch, and changed back to previous branch, you found out that all the changes are gone. How to retrieve code? This method may apply to other scenarios.
# to check the commit info and the abbrivation of commit-hashcode git reflog # to get the full information of logs. copy the hashcode git fsck --cache --no-reflogs # retrieve git reset $(hash-code)
Overwrite complete a branch
the production branch regularly
completely compy the latest verion of dev branch, and replace the old version(not merge) to avoid conflicts.
git checkout -B production_branch dev_branch