Fourth Area of Git
- To Collaborate between developers, we need code to be hosted
- Code can be hosted by any git server software/provider
- Gitolite
- GitHub
- GitLab
- BitBucket
- Code Commit
- Azure Source Repos
- Git to manage this will have a fourth area called as remote-repo
- Sending the commits to the remote repo is called as push and getting the commits from the remote repository is called as pull.
- If you don’t have a remote repository yet, but you have local repo then we would add a remote repository to local
- If you have remote repository and you want that code to local system then we perform clone
- Default Remote-repository will have a name which is origin
Scenario: You have a local repo and now you have remote repository created and want to send all the changes to remote repo.
- Connection between local and remote can be acheived by a command
git remote add --help # To know options
git remote add
Scenario: A New Developer wants to get the code from remote repository
- In this case as mentioned earlier, we need to use clone
git clone <remote-url>
Scenario: Move all of the code from one repository to other repository
- It is all about adding a new repository and pushing the changes from any developers machine
git remote add <newremote> <newremoteurl>
git push -u <newremote> <branch-name>
Scenario: Multi Developer UseCase
- Developer who is pushing the code to remote repository needs to be on latest version, so you have to do a pull before you push your changes.
- Best Practice: Get Periodic Updates from remote using pull operations
- Steps
Next Scenarios
- Merge Conflicts
- Multi Branches
- Rebase
- CherryPick
- Tags