windows10 use Git Github pushed directly to files and folders

0 Introduction

Installation and use Git under windows 10 system see my blog
below will be introduced in two ways

1 a first method

Create a warehouse, and then to a local warehouse clone, copy uploaded file to the appropriate folder to the next.

1.1 Creating github repository

First, you need to have a github account, and then build a warehouse in github,Note that this is the name of your local repository folder name
Here Insert Picture Description

1.2 Github connection with the local folder

First you have to download a Git, Git download and installation see my blog .
After installing Git, to the directory specified folder, right click and choose Git-Bash Here. This will generate a directory with the same name as the folder appeal warehouse
Here Insert Picture Description
appeal folder has four folders, create folders after the fifth running back in command, and the name of the warehouse of the same name.
In git bash, type:
git clone https:/github.com/****/Test.git
where the **** is your user name, Test can also change the name of your new warehouse, behind must add git.
Here Insert Picture Description
Then you will find more than a folder in a folder, the folder name and the name of the same warehouse.
Here Insert Picture Description
There is a hidden .git folders and files in a folder readme.md
Here Insert Picture Description
next need to do is copy the files you want to upload the file to the next Test.
Enter the git bash cd Testinto the test folder
Here Insert Picture Description
Then enter the following code to complete the upload.

git add . # 注意add空格后面有个.
git commit -m '随意是啥'
git push -u origin master # 此操作目的是把本地仓库push到github上面,此步骤需要你输入帐号和密码

Here Insert Picture Description
Upload local files to success.

The second method

Now create a local folder, use git to initialize, and then uploaded via ssh.

2.1 Create a folder

Create a Test folder
Here Insert Picture Description
in the folder, right-click, and then git bash.
Then will pop up a command line window, enter the command:
git init
Here Insert Picture Description
folder will generate a hidden folder .git, which is used to track and manage Git repository. Then copy your files to this folder, then git add .add all the files to the repository.
Here Insert Picture Description
Use git statusview the status
Here Insert Picture Description
and use
git commit -m '随意'
to submit items to the warehouse, but although submitted to the warehouse, but is not connected to github.

2.2 Creating github repository

Ibid,You need to build a warehouse on github

2.3 connected to the local github

Since the transmission between the local repository Github Git repository and encrypted by SSH, it is necessary to set the connection at:
Enter the following command in git bash.
git config --global user.name 'your name'
git config --global user.email 'your E-mail adress
User and mailbox modified according to the information you registered Github.
Then generate SSH key, enter the command
ssh-keygen -t rsa -C "your E-mail adress"
to open Github, click Settings in the picture below, then click the SSH and GPG keys, create a new SSH, name at random.
In Git bash input:
cat ~/.ssh/id_rsa.pub
outputs SSH, copy the contents of the output to github box, click on the ADD SSH key save.
Here Insert Picture Description
Then enter ssh -T [email protected], if shown in the figure appears, there has been your user name, it succeeded.
Here Insert Picture Description
After doing all of the above work, enter the git bash
git remote add origin https://github.com/***/Test.git
appear will be
Here Insert Picture Description
because, checked Initialize this repository when creating a warehouse with a README (when the warehouse is created automatically for you to create a README file), but the local folder no readme.md file, so it will error.

Then you need to enter
git pull origin master
the download readme.md file locally, and then upload and local synchronization
Here Insert Picture Description
git push origin master
Here Insert Picture Description

Published 21 original articles · won praise 1 · views 1104

Guess you like

Origin blog.csdn.net/Elenstone/article/details/105315419