Git & Github - 3
Git Branches
to create a branch git branch branchname
to change one branch t o another git checkout branchname
# Without commit in branch we should not check out to other branch, if not the information will come to other branch also
to delete branch git branch -d branchname
After commit we can observe the changes, we can say that, code will not be shown in master branch
to check how many branch have git branch
to rename the branch & if you are in other branch & rename previous branch
git branch –m oldname newname
to change the branch name , if you are in same branch &wants to change its name than git branch –m newname
git diff sample
(it will compare with master branch)
example
Git merger sample
(it will merger with master branch)
While checkout we want to create a new branch git checkout –b sample
How to push all branch to remote repo Git push sample --all
How to delete the branch git branch -d sample
Tags
Difference between branch & Tags
branch | tags |
it is mutable | immutable |
on development | after production development |
git branch | git tag |
git branch branchname | git tag tagname |
git push filename branchname | git push file nametag tagname |
git push filename -all | git push filename -tags |
git branch -d branch branchname | git push sample -tags |
Whatever the code which is their in branch will be created as zip file or tar file by tag command To delete
Subscribe to my newsletter
Read articles from Kusuma V directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Kusuma V
Kusuma V
Passionate about staying updated with the latest advancements in cloud computing and DevOps practices, I am committed to driving innovation and delivering value through technology.