GIT basic operations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.