git use
1. Set up personal information
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
2. Create a new Git repository in the directory
git init
3. Add files to the staging area
Add one or more files to the staging area:
git add [file1] [file2] ...
Add the specified directory to the temporary storage area, including subdirectories:
git add [dir]
Add all files in the current directory to the temporary storage area:
git add .
4. Submit the temporary storage area to the local warehouse:
git commit -m [message]
5. Synchronization of remote libraries
git pull origin master
git push origin master
Set up http, https proxy
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
View http and https proxy configuration
git config --global --get http.proxy
git config --global --get https.proxy
Cancel http, https proxy configuration
git config --global --unset http.proxy
git config --global --unset https.proxy
github use
1. Create SSH Key
In the user's home directory, check if there is a .ssh directory. If so, check if there are two files, id_rsa and id_rsa.pub, in this directory. If there are already, you can skip to the next step. If not, open Shell (open Git Bash under Windows) and create SSH Key:
ssh-keygen -t rsa -C "[email protected]"
Replace the email address with your own email address, then press Enter all the way and use the default value. Since this Key is not used for military purposes, there is no need to set a password.
If everything goes well, you can find the .ssh directory in the user's home directory. There are two files, id_rsa and id_rsa.pub. These two are the key pair of SSH Key. id_rsa is the private key and cannot be disclosed. id_rsa.pub It is a public key, so you can tell anyone with confidence.
Open id_rsa.pub and copy the content inside.
2. Add SSH
Log in to GitHub, open the "Account settings", "SSH Keys and GPG keys" page and click "New SSH Key", fill in any Title, and paste the content of the id_rsa.pub file in the Key text box.
3. Create a warehouse
Then you can create a repo, log in to GitHub, and find the "Create a new repo" button in the upper right corner to create a new repo.
4. Associated warehouse
You can see that the homepage provides two ways to associate with the local warehouse
method one:
Associate the existing local Git repository of the same name with the repository on GitHub
git init
Set the current folder as a Git repository
git commit -m "..."
Submit to local warehouse
git remote add origin [email protected]: GitHub account name/Gittest.git
Associated warehouse
After adding, the name of the remote library is origin, which is the default name of Git, and it can be changed to something else, but the name of origin is a remote library.
Next, you can push all the contents of the local library to the remote library
git push -u origin master
Since the remote library is empty, we added the -u parameter when pushing the master branch for the first time. Git will not only push the contents of the local master branch to the new remote master branch, but also the local master branch and the remote The master branch is linked, and the commands can be simplified in the future push or pull.
It can be used after git add git commit-m
git push origin master
You can upload your own code to the remote warehouse.