1 | git remote |
PartA. Add A Remote Repository
1. Create A Simple Project
Create a Project directory
git init
to turn it into a Git repositoryCreate a
README.md
fileCreate other files
2. Hosting on GitHub
Creat the repo on GitHub
3. Manage the Repository: git remote
1 | git remote |
- It’s possible to have links to multiple different remote repositories.
- A shortname is the name that’s used to refer to a remote repository’s location. Typically the location is a URL, but it could be a file path on the same computer.
git remote add
is used to add a connection to a new remote repository.git remote -v
is used to see the details about a connection to a remote.
PartB. Push Changes To A Remote
1. Check the commits
1 | git log --oneline --graph --all |
2. Push the commits
1 | git push <remote-shortname> <branch> |
PartC: Pulling Changes From A Remote
1 | git pull origin master |
When git pull
is run, the following things happen:
- the commit(s) on the remote branch are copied to the local repository
- the local tracking branch (
origin/master
) is moved to point to the most recent commit - the local tracking branch (
origin/master
) is merged into the local branch (master
)
PartD: Pull vs Fetch
1 | git fetch origin master |
fetch
the changes, but not merge
them