- Git
- Introduction
- here
Push a branch to a remote repository
Learn how to push a branch to a remote repository. It is assumed that commit is complete.
What is a remote repository
A remote repository is a remote repository. For example, a repository on Github.
Remote repositories can be represented using URLs.
#Represent remote repository with URL git@github.com:yuki-kimoto/perlzemigit.git
However, this is a hassle to remember, so most of the time you give it a name. Use the "git remote add" command to name it.
git remote add origin git@github.com:yuki-kimoto/perlzemigit.git
It is customary to name the default remote branch origin.
What is a branch?
I will explain about the branch of Git. A Git branch is a reference to a commit. Each commit is represented by a commit ID, but the first part where the commit ID extends is the branch.
main *-*-*-* | -*-* add_api
In Git, the default branch name is master. For users who imagine master as a slavery master, the new version of Git allows you to optionally give it a default branch name.
Local and remote repositories
In Git, both local and remote repositories had complete information about the entire file.
What is a push? Think of a push as doing two things:
1. Transfer information from the local repository to the remote repository
2. Align the beginning of the branch
Suppose your local repository is in the following state:
main *-*-*-*
Suppose the remote repository "origin" is in the following state.
main *-*-*
Pushing means transferring a new commit from your local repository to a remote repository and aligning your branches.
Push
Use the " git push" command to push. The arguments are the remote repository name and branch name.
git push origin main