Git contd
Remote Repository
- Overview


Local Repo first and then Remote Repo
- Create a local repo have atleast one commit
- Create a remote repo in github (or any other git remote repo)
- from local repo, establish a connection
git remote add <remote-name> <remote-url>
git remote add origin https://github.com/dummyrepos/my_first_git_repo_feb26.git
git config --list
- To send changes from local to remote the command is
git push <remote-name> <reference-name>
Remote first and then local
- you have a remote repo, but nothing local => clone
git clone <remote-url>
git clone https://github.com/dummyrepos/githublearningsep25.git
cd githublearningsep25
git config --list
Conditions
-
when we are connected to a remote repository a branch with name
<remote-name>/<branch-name> will be created locally which represents the remote
-
when we are pushing changes the tip of the remote branch and tip of your branch before this change should be same
- When we are getting latest chagnes
- changes are fetched from remote into
<remote/branch> then merged into local branch pull => fetch + merge
- Generally its a good idea to pull changes regularly from remote.
Exercise
- Create a Local Repo first make two commits in main branch and create a remote repo in github, push the changes after adding remote
- Create a remote repo add some changes there
- clone the repo
- make changes in local and push to remote
- make changes in remote and pull the changes
- make changes in local and also in remote
- use push to notice ther error
- Try pull to see Merge commit
- make changes in local and also in remote
- use push to notice ther error
- Try pull –rebase you should not see extra merge commit
- Create an extra branch in local and push