Remote Repository
- Remote Repository is git on other node (generally)
- Any node can host remote repositories. There are many softwares/platforms which can help us.
- Softwares:
- Gitolite
- Git-Lab (Hosted)
- Platforms
- GitHub
- BitBucket
- Code Commit (AWS)
- Azure Git Repos
- Softwares:
Remote Repository Scenarios
- Create a Local Repo first and push the changes to Remote Repository
- Clone the Local Repo using Remote Repository
Exercise on Remote Repository
- Create a Remote Repository for Local Repository (Ecommerce app)
- I will be using GitHub
- Created a new repo and got the url as https://github.com/GitPracticeRepo/ecommerceapp.git
- Push the changes from Local Repo to Remote Repo.
- Add this new url as your remote repository
git remote add <name-of-remote> <url> git remote add origin https://github.com/GitPracticeRepo/ecommerceapp.git
- Push the changes to Remote Repository
git push <name-of-the-remote> <branch-name> git push origin master
- Lets push other branches
git push origin sprint-1 git push origin sprint-2
- Clone a Local Repository from existing remote repository
- I will be using a Repository present at https://github.com/GitPracticeRepo/AnsibleSamples
- Clone a Local Repo from Remote Repo
git clone <url> git clone https://github.com/GitPracticeRepo/AnsibleSamples.git
How the Remote is Handled
-
Whenever a Remote Repo is added, new branches gets created in Local Repository. <Remote-name>/<branch-name> will be the name for the remote branch.
-
Sending the changes from local to Remote is Push
-
Getting the latest changes from Remote to local is Pull (Fetch + Merge)
Changing Hisory of commits
- Use Interactive Rebasing.
Cherry-Pick
- To pick individual/sequence of commit(s) from one branch to other use cherry-pick
- Refer Here
Bare Repositories
- Git repositiries with only .git folders
- Generally used on servers and also used for taking backup
git clone --bare <url>
One local Git Repo with multiple Remote Repos
git clone <url>
# a remote called as origin gets created
git remote add <other-repo-name> <other-repo-url>
Topics to be covered
- Git Communication Protocols
- Git Stash
- Git Tags
- Git Branching Strategy
- Git Reflog
- Git config
- Git Hooks/WebHooks
Exercises
- Demonstrate Fast-Forward
- Demonstrate Merge
- Demonstrate Rebase
- Remove 3 commits from histroy
- Combine 2 commits into one
- Get one commit from one branch to other
- Demonstrate Merge-Conflict