I remember that when I first met GitHub, I thought he was very high-end. I only knew that many cool people hosted code on it, but I still felt that it was far away from me. In fact, it is not actually very powerful.
If you are as confused as I was at the time, I hope my sharing will help you. (Record the process of self-use, Memo)
1. First step:
There is no doubt that the first step is to download git first. If you are a Windows user, go to the Windows version of git ~ I am a git of Win8. After downloading it, find git Bash. This is like a command line. You will perform a series of operations here. I also downloaded the local GitHub, but it is useless. I feel that GitHub on the webpage is quite useful. Don't forget to register it. Now we have all the preparations.
2. Second Step (create a personal homepage on GitHub ):
It depends on what you want to do, if you want to build a personal homepage on GitHub, there is a good article: http://www.ruanyifeng.com/blog/2012/08/blogging_with_jekyll.html
This article will teach you to build your own personal homepage on GitHub at, and you don't have to apply for domain names in disorder. You have a personal homepage, but it is static, it's not cool at all.
3. Third step (hosting code on GitHub ):
I originally wanted to create a personal homepage on GitHub, but it was not cool at all. If I did something wrong, I could do it myself. So I will host my code on GitHub ~ (Although the student Party has nothing to do, I cannot take the projects that I followed during my internship as a company, but I want to put some code I practiced first to develop a good habit of collecting data, there will definitely be a bike in the future), now start:
1. Create a project on GitHub
After logging on to GitHub, you can find a button "new repository" in the middle of the right side. After clicking it, enter the project name, description, and URL to create it, then, a prompt page appears, similar to [email protected]: xxx/xxx. git address. This is the address of your project.
2. Configure git and upload code
After successfully installing git, if you select git bash in Windows, it may be a bit difficult to complete everything in the command line, but remember the several command lines,
First, set git:
1 git config --global user.name "Your Real Name" 2 git config --global user.email [email protected]
Then start the most important step. You need to upload the file to GitHub's Git system, and you need an SSH key for authentication. Next we will start to generate the key and submit the key. Open git bash and create an SSH key:
1 ssh-keygen-C' [email protected] '-T RSA
Enter the location where the SSH key is stored. You can directly press enter to use the default path. Enter the password you want, And the SSH key is generated. Now you need to submit the key to GitHub. First open the key storage location, which contains three files, find id_rsa.pub, open it in a text editor, and copy all the characters in it. Go to GitHub and find account settings in the toolbar in the upper-right corner. On this page, there is an SSH public keys tag and select add another public key. You can enter either title or key to paste the character and submit it.
After completing these tasks, you can upload your own code. Find the code folder you want to share and upload, right-click and select git bash, or enter the folder in git bash. Create a warehouse
1 git init2 git add .3 git commit -m ‘Test‘4 git remote add origin [email protected]:XXX/XXX.git 5 git push -u origin master
This [email protected]: xxx/xxx. Git is the generated address for the project created above. Now, open your project URL and you will find that your code has been displayed. If you want to update the code, repeat the above steps.
4. forth step (Common Errors ):
During use, you may encounter various problems. I have found several possible solutions on the internet, paste them here, and try again.
If you enter $ git remote add origin [email protected]: djqiang (GitHub account name)/gitdemo (project name). Git
Error message: Fatal: remote origin already exists.
The solution is as follows:
1. Enter $ git remote RM origin first
2. Enter $ git remote add origin [email protected]: djqiang/gitdemo. Git. No error will be reported!
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 your GitHub installation path. my options are c: \ Users \ Asus \ appdata \ Local \ GitHub \ portablegit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8 \ etc.
5. Find a file named gitconfig and open it to delete the [remote "Origin"] line!
If you enter $ ssh-T [email protected]
Error message: Permission denied (publickey). Because the new key cannot be added to SSH, the connection to GitHub will fail.
The solution is as follows:
1. Enter $ ssh-agent first, 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 use the SSH tool of git GUI to generate the key. when the key is generated, it is directly saved in SSH. 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
Error message: Error: failed to push som refs .......
The solution is as follows:
1. First enter $ git pull origin master // first pull the file above the remote server GitHub
2. Enter $ git push origin master.
3. If the following 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 R epository.
4. Enter $ git remote add [email protected]: djqiang/gitdemo. Git again.
GitHub initial experience (for beginners of minor food, GitHub)