git proxy#
http proxy
git config --global http.proxy http://127.0.0.1:10808
git config --global https.proxy https://127.0.0.1:10808
Disable proxy
git config --global --unset http.proxy
git config --global --unset https.proxy
socks proxy
git config --global http.proxy socks5://127.0.0.1:10808
git config --global https.proxy socks5://127.0.0.1:10808
After my testing, using socks proxy with v2ray listening port can effectively accelerate git requests.
Step 1: Download and install git#
No need to teach this, those who don't know won't understand it either.
Step 2: Configure git private key#
1. Initialize your username and email, use the following commands.#
git config --global user.name "Enter your username"
git config --global user.email "Enter your email"
2. Open git bash and use git commands.#
3. Generate the key, use the following command.#
ssh-keygen -t rsa -C "email address"
# (First, ssh-keygen will confirm the storage location of the key (default is .ssh/id_rsa), then it will ask you to enter the key passphrase twice. If you don't want to enter the passphrase when using the key, leave it blank. However, if you use a passphrase, make sure to add the -o option, which will save the private key in a format that is more resistant to brute force attacks than the default format. You can also use the ssh-agent tool to avoid entering the passphrase every time.)
4. View the key, use the following command.#
cd ~/.ssh
5. Output the key, use the following command.#
cat id_rsa.pub
6. Copy the key, open gitlab, click on your avatar settings >> ssh Keys >> add the key.#
7. Set your own name as the title.#
Step 3: Initialize the folder with git init (/d/xiangmu).#
Step 4: Copy the files using git clone (git clone + path).#
Initialization
① Initialize git: git init
② Add all files of the project to the repository: git add .
③ Commit the added files to the repository
git commit -m "commit message"
④ Associate with the remote repository
git remote add origin https://github.com/YlyAyzbl/YlyAyzbl.github.io.git // your repository address
Check if the connection is successful:
git remote -v
Upload files
git push -u origin main
//main is the branch you want to upload to
At this point, you will be prompted to enter your gitlab account password
Check if the webpage is uploaded
The commit message is the content of the final submission prompt.
Force push to the remote repository and overwrite the remote code repository#
git push -f --set-upstream origin main:main
- Troubleshooting!
If the upload fails, it is recommended to start over and delete the already connected remote repository.
Don't panic when encountering problems, stay calm, and if all else fails, use the three magic tricks of operations and maintenance!
git remote remove origin // remove remote repository
git remote remove filename // remove file
git remote -v // check the current remote repository connection status
4. Update the remote repository address:
# Some remote repository branches have been deleted, but when you check with git branch -a, the deleted remote branch will still be displayed. You can refresh the local remote branch information by executing the following command.
git remote update origin --prune
Enter git branch -a
to view all branches of the remote project. The red branch represents the current branch, and the others listed are all branches.
Enter git log
to view the history of commit messages.
Enter git status
to check what content has been modified.
Enter git remote show origin
to view basic information about the current repository.
git mv <source> <destination>
Move a file to a new location and rename it.
Unable to query the contents of the repository through commands, can only be viewed by opening the webpage.#
For more information, please see
Git Simple Guide (bootcss.com)
Delete the repository and run away#
git rm -r *
git commit -m "Add description"
git checkout
git push