Upload local folder to Github
Step 1. Download git
Download the git client and install it locally.
Step 2. Create a new repository (Repository) in github
Step 3. Set SSH key
C:\Users\用户名\.ssh
Check whether the ssh key exists, and check whether the file exists in the local computer path ( )id_rsa.pub
, if it is as follows, go to step 4 directly.
- If
id_rsa.pub
it does not exist, enter the following command,
ssh-keygen -t rsa -C "email" # email为你在github上注册的邮箱
Then press Enter, you need to enter two strings to generate the key, remember these strings, you can submit them later, you can also press Enter directly, it is recommended to press Enter directly, and the following figure appears, indicating the key Generated.
3. Open C:\Users\用户名\.ssh
), id_rsa.pub
this already exists.
Step 4. Add SSH keys
Add SSH keys in the github setting, and follow the steps in the figure below;
Step 5. Upload local files to github
- First create a folder locally, named here
test
, and put the files to be uploadedtest
into the folder. - Right-click
test
the folder, openGit Bash Here
the pop-up command window, and enter the following statement to upload.
git init # 在此文件夹生成一个.git隐藏文件;
git add . # 将文件添加到缓存区( 注意这个".",是有空格的,"."代表这个test这个文件夹
#下的目录全部都提交,也可以通过git add 文件名 提交指定的文件);
git status # 查看现在的状态,也可以不看,随你啦,可以看到picture文件夹里面的内容都提交上去了;
git config --global user.name "your name" # "your name" 是github用户名字
git config --global user.email "your email" # "your name" 是github注册邮箱
git commit -m "这里是注释" # 提交添加到缓存区的文件
git remote add origin https://xxx@xxx/test.git
# 添加新的git方式的origin, github上创建好的仓库和本地仓库进行关联
git push origin master # 把本地库的所有内容推送到远程仓库(github)上,即上传本地文件。
If the image below is displayed, it means the upload is successful (the image comes from reference 1 ).
reference
[1] Upload local files (folders) to GitHub and update warehouse files
[2] Github implements local folder uploads