Since the use of GitHub, it has been uploading files to the repository online at the GitHub site, but sometimes the upload failed because of network or computer reasons. The most important reason is that I am used to editing locally and then uploading GitHub together. Read a few tutorials to summarize the most suitable for their own relatively simple method.
Two ways to upload local files to Github1. GitHub Online Upload Folder
Online upload can also upload the complete folder structure, directly dragged to the Upload File page box.
1.1 Click to upload a file
Click Upload 1.2 Direct drag
Simply drag and drop files in folders and folders. If you click Choose your files, you can only upload individual files.
Drag 2 directly. Upload local folder (local project) via Git tool 2.1 download git tools
Select the corresponding version download 2.2 After the download is complete, note that you can choose to create a desktop shortcut during the installation process
Desktop Shortcut 2.3 Binding user
Open Git-bash.exe (right-click directly on the desktop, or click the Start button to find Git bash)
Run Gitbash.gif
Enter the following command (user and mailbox for your GitHub registered account and email) in an open git bash
$ git config --global user.name "hanyuntao"$ git config --global user.email "[email protected]"
paste_image.png2.4 set SSH key (what does Sshkey do in git?) ) 2.4.1 Generate SSH key
First check whether the key has been generated cd ~/.ssh
, and if ls
there are 3 files returned, the key has already been generated.
Key generation
If there is no key, the
$ ssh-keygen -t rsa -C "[email protected]"
Generated, the process of generating a 3-time enter the return. (default path, default no password login)
After the build succeeds, go to the corresponding directory C:\Users\hyt.ssh (HYT for the computer user name, everyone different) with Notepad open id_rsa.pub, get SSH key public key.
SSH key Public key 2.4.2 Configure SSH key for GitHub account
Switch to GitHub, expand the small triangle of your profile picture, click Settings, then open the SSH keys menu, click Add SSH key to add the key, and fill in the title (preferably in accordance with the local repository).
Set Sshkey.gif
Then paste the key in the Id_rsa.pub file to this, and then add key to generate the key. \
2.5 Uploading a local project to github2.5.1 creating a local project
This is a few folders and files that I created myself.
Local Project 2.5.2 building a local warehouse
1. First enter the text folder
cd d:text
First go to the text folder
2. Execution instructions:git init
Execute git Init
After the initialization is successful you will find a hidden folder in the project. Git
Hidden folders
3. Execution instructions:git add .
Add all files to the warehouse
Executes git Add.
4. Execution instructions:git commit -m "提交文件"
Inside the double quotes is the commit comment.
Submit File
2.5.3 Associated GitHub Warehouse
1. Copy the warehouse address to the GitHub text warehouse
Copy Warehouse Address
2. Execution instructions:git remote add origin https://github.com/hanyuntao/text.git
5.
You can merge the code with the following command: Pull=fetch+merge
Git pull--rebase Origin master
5
After executing the above code, you can see that the local code base has more readme.md files
2.5.4 uploading Local Code
Execution Instructions:git push -u origin master
Execution command 2.5.5 completed.
You can see that our local project has been uploaded to GitHub.
Completed the
Note: Git cannot manage empty folders, and folders must have files to upload.
Uploading local documents to GitHub