Early registration of GitHub, but are in a state of bystanders. Recently I want to put their own code hosted on GitHub, use git tools to complete the data transfer.
First, reprint git installation and configuration (win10 version)
https://blog.csdn.net/huangqqdy/article/details/83032408
Two, git setup
1. Use git when the first associated with the remote repository on GitHub
(1) local directory initialize git
git init
(2) add a remote repository
git remote add origin https or ssh warehouse
2. Open the folder where the project
3. The cloned into the warehouse on the local GitHub
4. After cloning clone file appears in the folder in the folder will be displayed, the data is copied into a local clone of the repository
5. Then, as step
(1) into the folder cd XXX
(2) the file folder are added to come git add. (Add and have space before)
(3) git commit -m "Add Description"
(4) The data push to git push origin master (When prompted, enter account number and password GitHub) repository on GitHub in
GitHub refresh the upload is complete.
Problems encountered: non-fast-forward error if it is newly built warehouse may occur
Online access to a cause of the error https://www.cnblogs.com/chenyablog/p/9147932.html
Said first checked to eliminate differences in the local repository and a remote repository (remote and local synchronization) git pull origin master --allow-unrelated-histories
然后重新add,commit和push但是没有解决问题。
最后查阅资料使用了强制push来覆盖远程仓库的代码 git push --force 仓库的地址
https://blog.csdn.net/zyz00000000/article/details/84402189
至此我第一个GitHub项目上传成功。后续再传项目直接git push就成功了。
网上查阅了一下git push --force这种暴力的办法无法使代码退回旧版。