Git Contd
Git Rebase
- Refer Here for docs
- Git rebase is a command used to get changes from one branch onto another by rewriting history
- Consider the following situation where main has two commits after the sprint 0 branch was created
- Now we want the changes done in main branch to be part of sprint0 branch
- If we merge the changes from main into sprint 0
- If we rebase
- Rebase is useful for all the child branches but never rebase main/master from child as rebase rewrites history.
- To rebase checkout to sprint0 and rebase from main
git rebase main
Git cherry pick
- Refer Here for docs
- If we need to pick specific commits or specific range of commits (sequence) of commits , cherry pick can be used
- Now consider the following
- we need the changes form commit id
f3ae24b
in main branch - lets cherry pick
Remote Repository
- Git Remote Repository is any folder on any server
- To make Git Remote accessible, generally two protocols are widely used
- http(s)
- ssh
- There are many popular Git Repositories which are available for free.
- Today lets get started with GitHub
- Create an account in GitHub Refer Here
- Create a new repository in GitHub
- Now add this repository as remote to your local repository
- Now lets push the changes from local to remote
git push <remote-name> <branch/tag name>
- Now lets see all the branches in the repo
- The branches in remote represent remote branches
-
Now lets push the sprint 0 branch as well
-
In Organizations we will already have some repositories, Now to get the changes from remote to local we perform
clone
. Lets clone spring pet clinic
-
Summary