1. Create a new local warehouse
git init
2. Add files to the local warehouse
git add.
3. Submit files to the local warehouse
git commit -m "Project Description"
4. Push the local files to the coding server
git remote add origin https:// git .coding.net/username/project name.git
git push origin master
5. Problems encountered in the Push process and their solutions
(1) If there is no permission when pushing, and there is no prompt to enter the user name and password, the problem of 403 directly.
Solution: directly modify the url in the .git/config file:
https:// coding username: [email protected]/username/project name.git
or through the command:
git remote add origin https://coding username:[email protected]/username/project name.git
(2) If a (non-fast-forward) error occurs,
Method 1: You can directly use -f (force push)
git push –f origin master
Method 2:
1. git pull origin master --allow-unrelated-histories // Synchronize the remote warehouse with the local to eliminate the difference
2. Re-add and commit the corresponding files
3. git push origin master
4. At this time, the upload can be successful
6. git pull reports an error There is no tracking information for the current branch...
1. Use the git branch -vv command to query the relationship between the local branch and the remote branch.
Method 1:
1. Delete the branch that has not been associated and create a new one. Associated branch
git branch -D develop (note that you cut to the master branch first and then delete it)
2. git checkout -b develop origin/develop (the first develop is my local branch name, origin/develop refers to Remote branch, so that the newly generated local develop branch is already associated with the remote develop branch)
3. git branch -vv Check whether the association is really established
Method 2:
1. For the branch that has not been associated before, specify the remote branch that must be associated
git branch --set-upstream-to=origin/remote branch name, local branch name
, namely: git branch --set-upstream-to=origin/develop develop
2. Use git branch -vv to confirm whether the association is successful
7. Git report error: Couldn't find remote ref XXXX (gitlab report error)
XXXX does not appear to be a git repository Could not read from remote repository (github report error)
git report could not find remote repository error, unable to pull and push code
Solution:
1. Check the remote library connection: git remote -v
finds the remote library connection error, and need to re-establish the association
2. Clear the remote library connection: git remote rm origin
3. Re-establish the remote library connection: git remote add origin XXX (XXXX (Remote library url address)