Git is an open source distributed version control system that can efficiently and rapidly handle project versioning from very small to very large.
This article takes the example of using Git to upload a local project to GitHub, providing a way for those newcomers to git to upload a local project to the github/coding/code cloud using Git.
Sign up for a GitHub account and install Git
$ git config --global user.name "user.name"$ git config --global user.email "user.email"
Initializing the Git repository
$ git init
Add File
$ git add .
Note the following "." Don't forget to write. If you want to sync only one file, you can change the "." To the "file name" that you want to sync. Such as:
$ git add README.md
Add Comment
$ git commit -m "注释内容"
Establish an association with a remote github repository
The remote warehouse address is the new project address that you just added on GitHub https://github.com/user name/project name. Git
$ git remote add origin https://github.com/用户名/项目名.git
Sync to a branch of a new project in remote GitHub (default is General Master)
$ git pull origin master
Upload Warehouse to GitHub
$ git push origin master
If the following error occurs:
![rejected] master -> master (non-fast-forward)
The reason is that there is already a part of the code in the remote GitHub repository, so it doesn't allow you to overwrite your code directly. There are 2 workarounds:
Force overwrite, which forces your local code to replace the content in the remote GitHub repository:
$ git push --force origin master
Fetch the content from the remote GitHub repository first and then merge and push
$ git fetch
$ git merge
$ git push origin master
Refresh GitHub page and OK.
Use Git to upload local projects to github/coding/code cloud