Skip to content

Instantly share code, notes, and snippets.

@samarpanda
Last active June 3, 2020 06:35
Show Gist options
  • Save samarpanda/14b8a4fdd854b7176cf9 to your computer and use it in GitHub Desktop.
Save samarpanda/14b8a4fdd854b7176cf9 to your computer and use it in GitHub Desktop.
Git Command help docs for Komli
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
datekey=$(date +"%Y%m%d")
prereleaseTag=$datekey"_prerelease_"$branch
preTagMessage="Prerelease tag for branch: "$branch
releaseTag=$datekey"_release_"$branch
tagMessage="Release tag for branch: "$branch
echo "current released branch: "$branch
git tag -a $releaseTag -m "$tagMessage"
echo "Created Release tag : "$releaseTag
git checkout master
git pull origin master
git tag -a $prereleaseTag -m "$preTagMessage"
echo "Created Prerelease tag on master : "$prereleaseTag
git checkout $branch
git push --tags
echo "done"
exit 0;
#!/bin/bash
##
# Run process:
# sh create_komli_release_tags.sh -c try ## here -c is optional
# sh create_komli_release_tags.sh -d try ## create branch
##
#!/bin/bash
branch=${1:-DEFAULTVALUE}
flag=${2:--c}
setup(){
currBranch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
datekey=$(date +"%Y%m%d")
prereleaseTag=$datekey"_prerelease_"$branch
preTagMessage="Prerelease tag for branch: "$branch
releaseTag=$datekey"_release_"$branch
tagMessage="Release tag for branch: "$branch
echo "Start creating tags for released branch: "$branch
}
create_release_tag(){
git checkout $branch
git tag -a $releaseTag -m "$tagMessage"
echo "Created Release tag : "$releaseTag
}
delete_tags_done(){
git tag -d $prereleaseTag
git tag -d $releaseTag
echo "deleted_tags"
echo "done"
exit 0;
}
create_pre_release_tag(){
git checkout master
git pull origin master
git tag -a $prereleaseTag -m "$preTagMessage"
echo "Created Prerelease tag on master : "$prereleaseTag
}
push_and_done(){
echo "push tags to remote repository"
#git push --tags
git checkout $branch
echo "done"
exit 0;
}
if [ $branch != "DEFAULTVALUE" ]; then
git checkout $branch
if [ $? == "0" ]; then
setup
if [ $flag == "-c" ]; then
create_release_tag
create_pre_release_tag
push_and_done
elif [ $flag == "-d" ]; then
delete_tags_done
else
echo "invalid usage.. use -c(optional) to create and -d to delete tag"
exit 1;
fi
else
echo "Branch '"$branch"' doesn't exit in this repo"
exit 1;
fi
else
echo "invalid usage .. No branch name specified"
exit 1
fi
exit 0;

Komli Git Help Docs

Clone any of the komli repositories. cd into the directory before running any of the below commands.

Pullrequests

It is great if you could create a pullrequest for every changes your want to merge to master. This way we have can have a complete diff(single view) of codebase which was merged to master with the context. Easier to back track releases and the reason why we did some changes. We will plan to make it mandatory soon.

Cherry-pick commits between branches

## Pick and commit and hash and go the branch where you want to move this commit to and run the below command
git cherry-pick commit_hash

Create a new branch with master changes

## Fetch remote branches
git fetch
## Merge remote master branch in current active branch
git merge origin/master

## Fetch and merge
git pull

## Go to master branch
git checkout master
## Create a new branch from master
git checkout -b branch_name

Push local branch changes to remote

git push origin branch_name

Komli branch tagging convention before merging to master

Two tags should be created before merging any branch to master. Tag in master branch referred as prerelease and the tag in released branch is referred as release tag.

  1. Naming convention for release tag in released branch_name : YYYYMMDD_release_branch_name
  2. Naming convention for prelease tag in master branch : YYYYMMDD_prerelease_branch_name

** Here branch name is referred as the branch name which is supposed to be merged.

## Creating a tag
git tag -a tag_name -m "Comment for the tagging"

## Pushing all newly created tags
git push --tags

## Get all tags available for this repository
git tag --list

Delete Git tags (*Not advised)

let say we have a tag name delete_me

## delete local git tag
git tag -d delete_me

## delete remote git tag not advised
git push origin :refs/tags/delete_me

Note point

  1. git checkout master => Create prerelease tag here.
  2. git checkout branch_name => Create release tag here.

Git history

## To show last 10 commit history
git log -10 

To cover

  1. git rebase (squash, spliting)
  2. git submodule

Stellar links

Taggings
Cherry-pick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment