Creating a remote repository
1. New warehouse (take code cloud as an example)2. Fill in the warehouse information
3. Click the project you just created to copy the url of remote Git
4. Native code
4.1: If there is no native code
Start the Clone project code git Clone ******
Git commit -m
Commit to remote Git push -u Origin master
4.2 If local codes exist, idea is used as an example
Projects that do not have git connections do not have git options. Initialize Git first
You can run the git command in the current folder or in idea
The idea of operating
The command operation
git init // Initialize the repository
git add . // Add a file to the local staging area or use git add (file name)Git commit -m "First commit"// Commit to the local repository
git remote add origin // Add a remote repository
git push -u origin master // Push the master branch of the local repository to the master branch of the remote repository
Copy the code
Possible errors
1.GitHub Updates were rejected because the remote contains work that you do
The reason:
This is because the content of the remote warehouse is inconsistent with that of the local new library (some content of the remote warehouse is not available locally). So pull first
git pull origin master // Drop the remote master branch from the local master branch
Copy the code
2.refusing to merge Suggested histories
The reason:
The main reason for this problem is that the local and remote warehouses are actually separate repositories. This would not have been the case if I had cloned the github repository locally. You can use the — Allow-suggested – History option to solve the problem (the option can merge the histories of two independently launched warehouses).
git pull origin master --allow-unrelated-histories
Copy the code