Create Annotated Tag:
1 |
git tag -a M3 -m "Milestone 3" |
List Tags:
1 |
git tag |
Push Tag:
1 |
git push --tags |
Delete Tag Remotely:
1 |
git push origin :refs/tags/M3 |
Delete Tag Locally:
1 |
git tag -d M3 |
Create Branch:
1 2 3 |
git branch branch_name git push origin branch_name git push origin branch_name:features/branch_name |
Switch to new branch:
1 2 |
git checkout branch_name git checkout branch_name <hash tag> |
Create Branch without loosing current uncommitted modifications:
1 |
git checkout -b new_branch_name |
List all branches:
1 |
git branch |
Merge back to master
1 2 3 |
git checkout master git merge branch_name git push |
Delete old branch
1 2 3 4 |
git branch -d branch_name git branch -rd origin/branch_name git push --progress origin :branch_name git push origin :branch_name |
Good way to use feature branch and merging
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
git checkout -b bug100 develop #created new branch bug100 from develop #...do your stuff and push bug100 git checkout develop #checkout main branch develop git merge --no-ff --no-commit bug100 #merge bug100 back to develop branch #!don't forget to commit merged code git branch -d bug100 git branch -rd origin/bug100 #delete bug100 branch |
Soft reset last changes
1 |
git reset --soft |
Delete file remote but keep local copy intct
1 |
git rm --cached |
Show history
1 |
git log |
Checkout a specific revision
1 |
git checkout <hashtag> |
Checkout specific branch
1 |
git checkout --track -b local_branch_name origin/branch_name |
Show files different between 2 branches (master and develop)
1 |
git diff --name-status master develop |
List conflicted files
1 |
git ls-files -u |
Point head to a different branch
1 |
git remote set-head origin {{BRANCH NAME GOES HERE}} |
Clone entire repository with full history of all branches
1 2 3 |
git clone --bare http://my.server.com/old.git cd old.git git push --mirror http://my.server.com/new.git |
GitFlow Feature Branch
1 2 3 4 5 6 7 8 |
git checkout -b feature/my-feature develop git push origin feature/my-feature ...[implement stuff]... git pull origin develop git checkout develop git merge --no-commit --no-ff feature/my-feature git push git branch -d feature/my-feature |
GitFlow Release Branch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
git checkout -b release/API-2.4.7 develop git push origin release/API-2.4.7 ...[fix bugs, test] ... git checkout develop git pull git merge --no-commit --no-ff release/API-2.4.7 ... git checkout master git pull git merge --no-commit --no-ff release/API-2.4.7 ... git branch -d release/API-2.4.7 git tag -a API-2.4.7 -m "API-2.4.7" master git push --tags |
GitFlowTool new feature
1 2 3 |
git flow feature start TASK-2796_taskDetailsGoesHere ... do your stuff git flow feature finish TASK-2796_taskDetailsGoesHere |