1. Create a new project upload
cd parent_dir //进入项目父目录mkdir gitDemo //创建项目目录 gitDemocd gitDemo //进入项目目录git init //初始化空的 git 仓库touch README.md git add README.md //这两行添加简单的 README.md 文件git commit -m "first commit" //提交时附加的信息git remote add origin https://coding.net/codingTutorial/gitDemo.git //添加一个名为 origin 的远端( url 为 git 地址)git push -u origin master //将该目录下的文件推送到远端(origin)上的 "master" 分支
Problems that you may encounter
A. If you are using it for the first time, you will be prompted to set up your username and mailbox first, and you can enter it in cmd:
git config--global user.email "[Email protected]"
git config--global user.name "Your name"
B.git push failed with the following prompt
! [Rejected] Master--master (fetch first)
Error:failed to push some refs to ' https://github.com/dummymare/Hello-World.git '
Hint:updates were rejected because the remote contains work the
Hint:not has locally. This was usually caused by another repository pushing
Hint:to the same ref. Want to first integrate the remote changes
Hint: (e.g., ' git pull ... ') before pushing again.
Hint:see the ' Note about Fast-forwards ' "Git push--help ' for details.
Workaround:
Cause: There is a difference between the local version and the trunk before pulling the remote version, resolving the conflict to push
Git pull-u Origin master
and then
git push-u Origin master
GIT basic operations