Step 1: Create a git repository
cd to your local project root directory and execute the git command, which will create a .git folder in the current directory.
git init
- 1
Step 2: Add all files of the project to the repository
git add .
- 1
This command will add all files in the current path to the list of files to be uploaded. If you want to add a specific file, just replace . with a specific file name
Step 3: Commit the add file to the repository
git commit -m "注释语句"
- 1
Step 4: Go to github to create your own Repository, click NewRepository as shown below:
Click Create repository, you will enter a page similar to the following, and get the https address of the created repository
Step 5: Associate the local repository to github
git remote add origin https://自己的仓库url地址
- 1
The sixth step, upload the code to the github remote warehouse
git push -u origin master
- 1
After the execution, if there is no exception, the upload is successful after the execution is completed. You may be asked to enter the Username and Password in the middle. You only need to enter the github account and password.
Pull the git project to the local
1. Open the terminal and cd to the folder where you want to store the project
cd 文件夹
- 1
2. Enter git clone url, the url is the address of the project you want to pull
git clone url
- 1
3. The project was pulled successfully
If the modified project is to be uploaded to github
1. git add your changed files, if you want to upload all git add .
git add .
- 1
2. Execute git commit -m "comments to add"
git commit -m "注释"
- 1
3. git push upload, you may be asked to enter the github account and password as prompted.
git push
- 1
Modify the uploaded username and password
git config --global user.name "Your Name"
git config --global user.email you@example.com
- 1
- 2
View globally through vim ~/.gitconfig
git config user.name "Your Name"
git config user.email you@example.com
- 1
- 2
View locally through the .git/config
files in the current path
You can also modify the submitted username and email:
git commit --amend --author='Your Name <you@example.com>'
- 1
Author information submitted by git commit can be viewed through git log
git log
Reprinted from https://blog.csdn.net/xuzenghuifeng/article/details/77343792