- Developer will not be able to merge to Master, but they can create branch (e.g., Hotfix, Patch, Feature)
- After Developer checkout a feature branch (
git checkout -b feature/cool-new-feature
) and make changes (git push --set-upstream origin feature/cool-new-feature
), they can submit a Merge Request. - Master will be the one that accept/rejects/review Merge Requests
- After Merge Request submitted, any Master should review it and make decision whether to accept/reject/review it.
- If Merge Request accepted, remove the feature branch. The changes will be reflected to master (pending build process status)
Setting up Gerrit Code Review
cat ~/.ssh/id_rsa.pub
ssh-keygen -t rsa -C "email"
- Centralized: Mimics SVN, no local repository
- Patched workflow: Common used in linux kernel, Original git workflow, Send patch file and pass around (email). Don't trust anyone, see the intention only.
- Forked workflow: Fork -> Clone -> Checkout. Commit -> Push -> Pull Request.
- Branching workflow: Create branches for each contributor. Trust contributor.
- Scheduled (1 master, 1 development, several features, hotfixes, bug fixes branches). Using version as branch name / git flow. Example: Drupal.
- Continuous (1 master & several feature branches). Everything is equally important. Rely heavily on automated testing/gatekeeper (series of gated checkin/testing suites). Example: Git
- Use "resolves Issues #2" inside the commit message to automatically link issue with commit (also to change status of issue).
- Bisect
- Version:
git --version
- Help:
git help all
- Clone:
git clone <giturl> [foldername]
| Clone from local repo:git clone <git folder path> [foldername]
>>git remote -v
show local remote - History:
git log
&git log --oneline
- Graph & GUI:
git log --oneline --graph
&gitk
- Config:
git config [--global|--local] user.email 'email.com'
- Initialized a directory:
mkdir <project>
,cd <project>
, &git init
- Check untracked files:
git status
- Add untracked files
git add <file>
&git add .
- Commit:
git commit [-m <comment>]
- Show remote repos:
git remote
&git remote -v
- Copying snapshot just by
cp <cloned_repo> <new_repo>
include remote - Add remote repos:
git remote add <remote_name> <remote_repo_path_or_url>
- Show Branches (all & remotes):
git branch -a
&git branch -r
- Update branches:
git fetch
- Checkout a branch: local:
git checkout <branch_name>
& remote with tracking:git checkout --track <remote>/<branch_name>
. If only have 1 remote, no need to use remote name. - Create a new branch from existing branch:
git checkout -b <new_branch_name> <from_branch_name>
- Delete a branch
git branch -d <branch_name>
- Change commit message
git commit --amend
- Push commits & branch:
git push --set-upstream <remote> <branch>
& subsequentgit push
- Merge from:
git merge <branch_name>
- Difference between 2 points in history: Commits:
git log HEAD^
& Commits changes:git diff HEAD^