Collection of git Commands by Category
Fetching a repo
Clone a Git repository.
1
| git clone https://github.com/[account]/[repo-name].git
|
To perform various remote actions such as git remote and push, an ACCESS TOKEN is required. In this case, clone can also be done using the ACCESS TOKEN.
1
| git clone https://[ACCESS_TOKEN]@github.com/[account]/[repo-name].git
|
Connecting to a remote
Registering an account
Basically, to connect remotely and perform commit and push, you need to register your account and enter your own token.
1
| git config --global user.name [account]
|
Connecting to a remote
origin is commonly used as the name of a remote repository. It does not necessarily have to be origin.
1
| git remote add origin https://github.com/[account]/[repo-name]
|
In this case as well, you can connect using an ACCESS TOKEN.
1
| git remote add origin https://[ACCESS_TOKEN]@github.com/[account]/[repo-name]
|
Removing a remote connection
1
| git remote remove origin
|
Uploading files
Adding files
1
2
3
| git add .
git add -A
git add -p #patch
|
Removing a file from the index
1
| git restore --staged [filename]
|
Committing
I find the first commit method more convenient. If you commit using the first method, the vim editor opens, where the first line is automatically recognized as the commit title, and after one blank line, the rest is automatically recognized as the commit content.
1
| git commit -m "[commit message]"
|
Uploading
1
| git push -u origin [branch name]
|
Branch
NEW Branch
name is the name of the new branch to create, and the branching point is the name of the branch to branch from.
1
| git branch [name] [branching point]
|
DELETE Branch
Renaming
1
| git branch -m [old name] [new name]
|
Switching Branch
Branch status