1. Install Git Tools
1) Download and install Git tools: Git Download
the installation is complete, right-click the desktop space, the following options:
2. Initialize the environment
1) In a folder, right click and select the image above
Git Bash Here
, enter a window interface:
2) Enter the command:
git config --global user.name "输入你的Github的账号"
Enter the command again:git config --global user.name "输入你的Github的邮箱"
3) Github account settings SSH key, enter the command:
ssh-keygen -t rsa -C 'Github的邮箱'
window prompts all choose not to ignore all press Enter
generated files willC:\Users\saibiao\.ssh
be found, I was here generates two files, in fact, need three files, the following there will be a solution.
Open the file inid_rsa.pub
the file, copy all
4) Open the GitHub page, suspended on a personal icon, click
Settings
, findSSH keys
and select newSSH Keys
,Title
can be set to the repository name, copy the public key to paste the entire contents of the box, click Add, you will receive e-mail alert
5) associated with the remote repository: Open the needs associated Depot home, copy the SSH link
Rungit remote add origin SSH地址
, which origin is from the local warehouse name
3. Start Push file
1) Enter the command window:
git init
to complete the initialization
2) add a file:touch demo.html
3) add files to the cache library:git add .
4) submission of documents to the repository:git commit -m "备注"
5) to submit files to a remote database:git push -u origin master
6) The fifth step in which the problem may occur if the following situations arise, we enter yes
This step is to generateknown_hosts
file
也可能出现
refusing to merge unrelated histories
这个错误,原因是本地仓库是远程仓库不一致,可以先拉取远程仓库到本地,再推送。
解决办法-输入命令:git pull origin master --allow-unrelated-histories
,成功拉取之后,再输入命令:git push -u origin master
即可