Git common commands and solutions to common errors

1. Go to the directory

$ Cd path (directory address)

If you feel that each entry must enter a lot of trouble, you can (1) behind the target .exe -to ~ deleted starting position (2) Git Bash changed to address local warehouse

After the open Git Bash will default to the local repository under


2. Return to the parent directory

$ cd .. 

3. Configure identity

(1) Set identity

$ git config --global user.name "Liber"

$ git config --global user.eamil "[email protected]"

(2) read identity

$ git config --global user.name

$ git config --global user.email

Figure:


4. Create a local code repository

(1) into the project directory

(2)$ git init




5. from a remote repository (GitHub) was cloned into the local

It requires (1) a remote Git repository address


(2) $ git clone [email protected] I: Chouett / coolweather.git / git clone + Go 地址

(3) After cloning is generated in the local repository directory in a remote repository Git named folders copied to the local repository directory (parent directory also has a .gitignore files, direct replacement line), copied can be remote repository folder deleted out.

6. Check all files in the current directory 

$ Ls -al

Figure:


7. will submit the file to the local repository Githu (remote repository)

(1) arranged to local key Git GitHub

(2) disposed in the distal end address Gitbash

Check the remote address $ git remote -v

View Configuration $ git config --list

$ Git remote set-url origin remote address


(3) submit the local repository

$ git add .

$ Git commit -m "submit"

$ git push origin master

1. The use of push force:

$ git push -u origin master -f

It would be modified remotely loss is generally not advisable, especially when many people work together to develop.

2.push remote repository before the first modified pull down

$ git pull origin master

$ git push -u origin master

3. If you do not want to merge remote and local changes, you can create a new branch:

$ git branch [name]

Then push

$ git push -u origin [name]

7.

Check local public

$ Cat ~ / .ssh / id_rsa.pub (available first $ cd ~ / .ssh enter to see if there id_rsa.pub, if you do not need to be regenerated)

Create a local public key: $ ssh-keygen -t rsa -C "[email protected]"




Guess you like

Origin blog.csdn.net/qq_41850194/article/details/79753840