Git uploads local files to GitHub
1 git config --global user.name "Your Real Name" 2 git config --global user.email [email protected]
git init
git add .
git commit -m ‘Test‘
git remote add origin [email protected]:XXX/XXX.git 3 git push -u origin master
Some possible problems are solved: If you enter $ git remote add origin [email protected]: djqiang (GitHub account name)/gitdemo (project name ). git prompts error message: Fatal: remote origin already exists. solution: 1. Enter $ git remote RM origin2 and $ git remote add origin [email protected]: djqiang/gitdemo. git won't report an error! 3. If you enter $ git remote RM origin or report an error, error: cocould not remove config section 'remote. origin '. we need to modify the content of the gitconfig file 4. Find the installation path of your GitHub, my is C: \ Users \ Asus \ appdata \ Local \ GitHub \ Users \ etc5, find a file named gitconfig, open it and delete the [remote "Origin"] line in it! If you enter $ ssh-T [email protected], the error message "Permission denied (publickey)" is displayed. Because the new key cannot be added to SSH, the connection to GitHub may fail. Solution: 1. Enter $ ssh-agent and then $ ssh-add ~ /. Ssh/id_key. 2. If the problem persists, enter ssh-add ~ /. An error occurs after the ssh/id_key command: cocould not open a connection to your authentication agent. the solution is to generate the key using the SSH tool of git GUI, so that the key will be saved directly in SSH when the key is generated. You do not need to add the ssh-add command. Other users, the token and other configurations are all done using the command line. 3. Check that there are no extra spaces or blank lines when you copy the content of the id_rsa.pub file. Some editors will help you add these lines. If you enter $ git push origin master, an error message is displayed: Error: failed to push som refs ....... Solution: 1. First enter $ git pull origin master // first pull down the file above the remote server GitHub 2. Then enter $ git push origin master3. If an error occurs, fatal: couldn't find remote ref master or fatal: 'origin' does not appear to be a git repository and fatal: cocould not read from remote repository.4. Enter $ git remote add [email protected]: djqiang/gitdemo again. git uses Git to create a project locally $ makdir ~ /Hello-world // create a project hello-World $ Cd ~ /Hello-world // open this project $ git init // initialize $ touch readme $ git add readme // update the README file $ git commit-m'first commit '// submit the update, and comment out the information "first commit" $ git remote add origin [email protected]: defnngj/hello-world.git // connect to remote GitHub project $ git push-u origin master // update local project to GitHub Project