第一次用git

来源:互联网 发布:空间网络音乐怎么删除 编辑:程序博客网 时间:2024/05/17 01:30

1.首先我是克隆项目 git clone

这是就会弹出Git命令行,并且自动切换到当前所在目录,我们运行

git init git add "某文件" //把该目录下的所有文件全部提交到缓冲区 git add . //把所有文件都提交到缓存空间git commit -m "GitHelloWorld first commit" //说明 

将代码提交到HEAD,注意此时还没有提交到服务器,下面将提交

git remote add origin https://git.oschina.net/xxx/xxx.git//具体看项目 git push origin master//可能出现Non-fast-forward问题 

查看提交的代码修改 git log --stat

git show

今天add origin遇到一个问题,untracked files,

解决办法就是把没有跟踪到的文件add进去 ,例如:输入命令 git add index.html


git提交的时候git commit -m "" 记得引号不要写成中文的引号


pull的时候遇到问题

I am using git via the terminal on the mac. I have encountered an annoying problem recently when I try to perform git pull. After performing git pull I receive the following error message:

Merge ssh://domain.com/repository.git# Please enter a commit message to explain why this merge is necessary,# especially if it merges an updated upstream into a topic branch.## Lines starting with '#' will be ignored, and an empty message aborts:# the commit.

The issue is that I can't enter anything. My terminal seems stuck and there isn't anything I seem to be able to do about it. I am reasonably new to git so it may be a simple mistake I am making.

I read here that for some people the text editor opens at this point. This certainly isn't the case at my end. It also states there that I can use the --no-edit flag to merge without a message, but even this does not seem to work at my end.

I am a bit clueless at the moment, stuck and unable to push any changes to my server ;-)

Thank you very much for any help provided!

解决办法:

To solve this:

  1. press "i"
  2. write your merge message
  3. press "esc"
  4. write ":wq"
  5. then press enter

原创粉丝点击