git Tutorial
Introduction Installing Git Understanding Git architecture Initializing the new Git respository Cloning new Git repository .git directory in Git repository Viewing Git configuration First time Git configuration Using SSH keys with Git Checking Git status Adding files into staging area in Git Committing changes to the local repository Ignoring files using .gitignore Viewing the history of commits Viewing the file contents in working directory, staging area and repository Viewing difference between files Viewing the history of files Git revert Git Reset git reflog Creating and switching to new branches in Git Viewing existing branches Merging branches Resolving conflicts Rebase Deleting branches Renaming the branch in Git Push Pull Stashing the changes in Git Tags in Git Patches in Git Creating new repository on GitHub Pushing local repository to remote repository like GitHub IntelliJ IDEACreating new branches in git
Branches are used to develop the code independent of main branch. Main advantages of Git branch are –- separates main development work from small tasks.
- You can easily context switch between different tasks.
- Allows you to work on specific features or functionalities of the application. You merge your work in main branch only when your branch code is finished and working properly.
- Allows you to provide hot bug fix easily without affecting what you are doing currently.
git branch x
To check out above branch in working copy, you have to use below command.
git checkout x
To create a new branch and check it out in working copy at the same time, you have to use below command. It will create new branch b2 and check it out.
git checkout -b b2
creating new branches and checking out in Git After a branch is created and checked out, you can make changes to files, add them to staging area or commit them. Once you are finished with all your changes, you can merge your branch in to main branch. You can also create a branch off specific commit using below syntax.
git branch branch-name <commit Id>
git branch branch-name HEAD~3
git checkout -b new_branch v1.2 : creating branch off tag
Here is the output of above example.
Web development and Automation testing
solutions delivered!!