Git uploads local files to Github

git config –global user.name “Your Real Name” git config –global user.email [email protected]

git init

git add .

git commit -m ‘Test’

git remote add origin [email protected]:XXX/XXX.git

git push -u origin master

Some possible problems to be solved:

If you enter git remote add origin [email protected]:test (github account name) /gitdemo (project name). Git prompts error message fatal: remote origin already exists.

The solutions are as follows:

  1. git remote rm origin
  2. git remote add origin [email protected]:test/gitdemo.git
  3. Git remote rm origin error: Could not remove config section ‘remote.origin’. You need to manually modify the contents of the gitconfig file
  4. Modify the. Git /config file in the repository and delete the configuration related to [remote “origin”]

If SSH -t [email protected] is entered, an error message is displayed: Permission denied (publickey), because the newly generated key cannot be added to SSH, github cannot be connected.

The solutions are as follows:

  1. Enter ssh-agent and ssh-add ~/. SSH /id_key.
  2. Ssh-add ~/. SSH /id_key Could not open a connection to your authentication agent The solution is to use the SSH tool of Git Gui to generate the key. In this way, the key is directly saved in SSH. There is no need to use the ssh-add command to add the key.
  3. It’s a good idea to check to see if there are any extra Spaces or empty lines when you copy the contents of the id_rsa.pub file. Some editors will add these for you.

Git push origin master error: Failed to push som refs to… The solutions are as follows:

  1. Git pull origin master // Pull down the file on github
  2. Git push Origin master
  3. Fatal: Couldn’t find remote ref master or fatal: ‘origin’ does not appear to be a git repository or fatal: Could not read from remote repository.
  4. The need to input $git remote add [email protected]: djqiang/gitdemo git

The process of creating a project locally using Git

$git init $git add README $git add README $git add README $git commit -m 'first commit' $git remote add origin [email protected]:defnngj/hello-world. Git // Connect remote Github project $git push -u origin Master // Update local project to Github projectCopy the code

Create a new repository on the command line

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:teamtogether/TestProject.git
git push -u origin master
Copy the code

Push an existing repository from the command line

git remote add origin [email protected]:teamtogether/TestProject.git
git push -u origin master
Copy the code