git使用说明

摘要:
初次使用请参考百度,google,博客园。1修改文件并提交到github[luwenwei@dev01v~/git/helww/labs]$vimREADME[luwenwei@dev01v~/git/helww/labs]$gitdiffdiff--gita/READMEb/READMEindex39d8172..464c83f100644---a/README+++b/README@@-3,3+3,4@@Thisismygithubwebsite.Welcome!Hereisintroduction:1,labsismylab,wheresomejoycodeisput2,thismaybeisnotproject,butwhoknows+3,andsomeusefultestcase[luwenwei@dev01v~/git/helww/labs]$gitcommitREADME-m"smallchange"[masterb8bc06a]smallchange1filechanged,1insertion(+)[luwenwei@dev01v~/git/helww/labs]$gitpushoriginmasterREADMEEnterpassphraseforkey'/home/luwenwei/.ssh/id_rsa':error:srcrefspecREADMEdoesnotmatchany.error:无法推送一些引用到'git@github.com:helww/labs'[luwenwei@dev01v~/git/helww/labs]$gitpushoriginmasterEnterpassphraseforkey'/home/luwenwei/.ssh/id_rsa':Countingobjects:8,done.Deltacompressionusingupto2threads.Compressingobjects:100%(6/6),done.Writingobjects:100%(6/6),695bytes,done.Total6,reused0Togit@github.com:helww/labsf005d79..b8bc06amaster-˃master解释:gitpushoriginmasterREADME这句的意思是提交本地的commit到远程仓库,README是要提交的文件,但是此命令执行失败。

初次使用请参考百度,google,博客园。这里也有一篇入门指南,简练精彩:http://www.kechuandai.net/git%E4%BD%BF%E7%94%A8%E5%B0%8F%E8%AE%B0/

我把自己碰到的问题记录下,备忘。

1 修改文件并提交到github

[luwenwei@dev01v ~/git/helww/labs]$ vim README

[luwenwei@dev01v ~/git/helww/labs]$ git diff 
diff --git a/README b/README
index 39d8172..464c83f 100644
--- a/README
+++ b/README
@@ -3,3 +3,4 @@ This is my github website. Welcome!Here isintroduction:
 1, labs is my lab, where some joy code isput
 2, thismaybe isnot project, but who knows
+3, and some useful testcase

[luwenwei@dev01v ~/git/helww/labs]$ git commit README  -m "small change"[master b8bc06a] small change
 1 file changed, 1 insertion(+)
[luwenwei@dev01v ~/git/helww/labs]$ git push origin master README
Enter passphrase for key '/home/luwenwei/.ssh/id_rsa': 
error: src refspec README does not match any.
error: 无法推送一些引用到 'git@github.com:helww/labs'
[luwenwei@dev01v ~/git/helww/labs]$ git push origin master 
Enter passphrase for key '/home/luwenwei/.ssh/id_rsa': 
Counting objects: 8, done.
Delta compression using up to 2threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 695bytes, done.
Total 6 (delta 1), reused 0 (delta 0)
To git@github.com:helww/labs
   f005d79..b8bc06a  master -> master

解释:

git push origin master README

这句的意思是提交本地的commit到远程仓库,README是要提交的文件,但是此命令执行失败。

正确的命令是:git push origin master(把一次本地commit提交到远程仓库)

2 问题:git push提示origin似乎不是repo

[luwenwei@appdev115 ~/git/helww/labs]$ git pull origin master
fatal: 'origin'does not appear to be a git repository
fatal: Could not read fromremote repository.

Please make sure you have the correct access rights
and the repository exists.

[luwenwei@appdev115 ~/git/helww/labs]$ git remote add origin git@github.com:helww/labs.git

[luwenwei@appdev115 ~/git/helww/labs]$ git pull origin master                             
The authenticity of host 'github.com (192.30.252.131)' can't be established.
Are you sure you want to continue connecting (yes/no)?yes
Warning: Permanently added 'github.com,192.30.252.131'(RSA) to the list of known hosts.
Enter passphrase for key '/home/luwenwei/.ssh/id_rsa': 
来自 github.com:helww/labs
 * branch            master     ->FETCH_HEAD
Already up-to-date.

[luwenwei@appdev115 ~/git/helww/labs]$ git push origin master
Warning: Permanently added the RSA host key for IP address '192.30.252.129'to the list of known hosts.
Enter passphrase for key '/home/luwenwei/.ssh/id_rsa': 
Counting objects: 6, done.
Delta compression using up to 2threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 653bytes, done.
Total 5 (delta 0), reused 0 (delta 0)
To git@github.com:helww/labs.git
   b8bc06a..913fe29  master -> master

解决步骤:1,git remote add origin;2,git pull origin master

1建立本地和远程的映射;2,拉远程代码到本地

3 查看本地修改列表:git diff --name-status

[luwenwei@dev01v ~/project/smartcloud/iot_biz]$ git diff  --name-status 
M       deploy/conf.sh
M       deploy/deploy.sh
M       project/autoload_builder.sh
M       project/build_includes.php
M       src/domain/knowledges/constants.php
M       src/proxy/http_proxy.php
D       tags
M       tasks/common_task_header.php
M       test/global.php
M       test/junit.xml

4 查看本地文件状态:git status(比git diff --name-status好的地方是能把新增的文件也列出来)

[luwenwei@dev01v ~/project/smartcloud/iot_biz]$ git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add/rm <file>..."更新要提交的内容)
#   (使用 "git checkout -- <file>..."丢弃工作区的改动)
#
#    修改:      deploy/conf.sh
#    修改:      deploy/deploy.sh
#    修改:      project/autoload_builder.sh
#    修改:      project/build_includes.php
#    修改:      src/domain/knowledges/constants.php
#    修改:      src/proxy/http_proxy.php
#    删除:      tags
#    修改:      tasks/common_task_header.php
#    修改:      test/global.php
#    修改:      test/junit.xml
#
# 未跟踪的文件:
#   (使用 "git add <file>..."以包含要提交的内容)
#
#    config/server/server_conf.php.lww
#    deploy/check.sh
#    deploy/deploy-beta.sh
#    src/logic/mnpartner_logic.php
#    src/service/amap_svc.php
#    src/service/position_svc.php
#    tasks/mn_fridge_cosumer.php
#    tasks/mn_fridge_producer.php
#    test/biz-process_log
#    test/env.php
#    test/test_AmapService.php
#    test/test_MnPartnerLogic.php
#    test/test_PostionService.php
#    tools
修改尚未加入提交(使用 "git add" 和/或 "git commit -a"

免责声明:文章转载自《git使用说明》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇element ui设置表格表头高度和每一行的高度vscode 用户设置与工作区设置下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Jenkins代码自动部署相关文档

环境 centos 7.0+ Java JDK 1.8+ jenkins 2.220 maven 3.0+ git 1.8+ 注意事项 一. linux 安装 JDK (jdk-8u201-linux-x64.tar.gz) 1.下载jdk 2.在/usr 目录下,新建 /java 目录, 3.在/java 目录下,新建/jdk目录, 4.把jdk-...

elixir mix开发入门

备注:  简单使用mix 进行项目的生成,同时添加docker 构建支持 1. 生成项目 mix new mydemoproject 输出信息如下: * creating README.md * creating .formatter.exs * creating .gitignore * creating mix.exs * cre...

gitlab介绍与操作

Gitlab GitLab 是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托管的 Git 项目仓库,可通过 Web 界面进行访问公开的或者私人项目。 与 Github 类似,GitLab 能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访 问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(W...

Shell学习(五)Shell输出命令

一、echo命令 #1、直接显示字符串 echo "It is a test" #输出:It is a test #2、显示转义字符 echo ""It is a test"" #输出:"It is a test" #3、显示变量 name=Shell echo "$name It is a test" #输出:Shell is a test #4、...

在重命名SqlServer数据库时,报5030错误的解决办法

数据库不能重名名5030的错误,其实很简单原因就是有应用程序正在占用这个连接,使用这样一行命令就可以查询出正在占用的连接 use master select spid from master.dbo.sysprocesses where dbid=db_id('数据库原名') 执行下面这条语句杀掉连接进程就OK了 use master kill 54...

python+unittest+requests实现接口自动化的方法

前言: Requests简介 Requests 是使用Apache2 Licensed许可证的 HTTP 库。用 Python 编写,真正的为人类着想。 Python 标准库中的 urllib2 模块提供了你所需要的大多数 HTTP 功能,但是它的 API 有点落后了。它是为另一个时代、另一个互联网所创建的。它需要巨量的工作,甚至包括各种方法覆盖,来完成最...