Git version management tutorial, git management tutorial
Git version management tutorial
For a long time, run the command directly ~
Create a local repository
git init
Obtain a remote Repository
git clone [url]
Create a remote Repository
// Add a new remote repository git remote add [remote-name] [url] // list all remote aliases git remote // list all remote urlgit remote-v/ /delete a renotegit remote rm [name] // rename remotegit remote rename [old-name] [new-name]
Delete from local repository
Git rm file.txt // remove from the version library, delete the file git rm file.txt-cached // remove from the version library, do not delete the original file git rm-r xxx // Delete the specified folder from the version Library
Add new files from the local repository
Git add. // add all files git add file.txt // add the specified file
Submit the cache content to the HEAD.
Git commit-m "comment"
Undo
// Cancel the latest commit. git revert HEAD // cancel commit + addgit reset -- mixed // cancel commitgit reset -- soft // cancel commit + add + local workinggit reset -- hard
Push local submission to remote server
git push [remote-name] [loca-branch]:[remote-branch]
View status
git status
Download new changes from remote database
git fetch [remote-name]/[branch]
Merge the downloaded changes to the Branch
git merge [remote-name]/[branch]
Download new changes from remote database
pull = fetch + mergegit pull [remote-name] [branch]
Branch
// List branch git branch // create a new branch git branch (branch-name) // delete a branch git branch-d (branch-nam) // Delete the remote branch git push (remote-name) :( remote-branch)
Switch Branch
// Switch to a branch git checkout [branch-name] // create and switch to the branch git checkout-B [branch-name]
The following is SSH authentication, which avoids Frequent password input for ease of use.
First, create an ssh key.
ssh key must begin with 'ssh-ed25519', 'ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', or 'ecdsa-sha2-nistp521'. -- from github
Based on the above sections, we can know the ssh key types supported by github. Here we create an ssh-rsa key. Enter the following command in command line: ''ssh-keygen-t rsa ''to create an ssh-rsa key. If you do not need to create a password or change the name for your key, press enter all the way to OK. If you need it, Google Translate it on your own because it is only an English problem.
$ Ssh-keygen-t rsaGenerating public/private rsa key pair. // you can determine your path based on the path in brackets. enter file in which to save the key (/c/Users/Liang Guan Quan /. ssh/id_rsa ):
Add a new SSH key to the https://github.com/settings/keys address, copy the content text under your xx. pub file to the Key text field, and then submit.
UseSsh git@github.com command to connect github, if you see your github account name in response, it means the configuration is successful.Let's enjoy github ;)
Finally, ignore the file
Create the. gitignore file in the root directory of the local repository. You cannot create a ". gitignore." file directly under Windows 7. The punctuation marks are automatically ignored;
/. Idea // filter all the content in the/fd/directory under the root directory/fd/*. iml // filter all the specified files !. Gitignore // do not ignore this file