GIt Basic

作者: stutterr | 来源:发表于2017-07-14 16:03 被阅读12次
  1. ssh-keygen 在本地电脑中中生成钥匙
  2. 打开公钥id-rsa.pub ,将公钥copy到git网站的SSH KEYS 中。
  • git clone 将服务器中的代码git到本地,copy项目网页上的ssh连接
  • 提交代码
  1. 先创建一个branch ,进入项目目录,输入命令行git branch username 这个样就创建了一个本地的branch.
    输入git checkout username转到当前branch
    git branch 查看本地多少branch. 查看远程分支
    git branch -r
  2. 在目录中添加新文件后,可以git status 看一下文件改变状态
  3. 之后git add 确定添加 参数-u 代表更新的代码, 参数-A 表示所有,add到本地仓库
  4. 之后git commit -m "作用" 将,参数-m表示本次提交描述,表示确认提交到本地仓库
  5. git push -u orgin youbranch 提交到远程
    注:
  • $ git push -u origin master //第一次提交添加命令参数 -u 确保关联本地库和远程库
  • $ git push origin master //非第一次提交使用此命令即可)

如果出现报错

$ git push -u origin master命令的时候报错:To git@github.com:xxx/xxx.git 
! [rejected] master -> master (fetch first) 
error: failed to push some refs to 'git@github.com:xxx/xxx.git' 
hint: Updates were rejected because the remote contains work that you do 
hint: not have locally. This is usually caused by another repository pushing 
hint: to the same ref. You may want to first integrate the remote changes 
hint: (e.g., 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因是没有同步远程的master,所以需要先执行命令git pull origin master同步代码
之后就可以同步了。

  1. git pull -r 将项目代码拉到本地。

相关文章

  • 常用的Git指令

    Git 命令https://www.runoob.com/git/git-basic-operations.htm...

  • git基本使用命令

    (git下载地址) Git学习地址 http://www.yiibai.com/git/git_basic_con...

  • Windows git remote: HTTP Basic:

    1 问题描述: git push/ git fetch/ git pull,报 HTTP Basic: Acces...

  • Git

    Git Local Install Git Basic Skills Check Time Travel Remo...

  • git常用操作

    Basic Operation 分支管理切换分支git checkout git checkout -b #...

  • git使用中各类问题汇总

    git 报 HTTP Basic: Access denied 今天pull代码发现git 报错: git rem...

  • Git 记录

    参考: https://www.yiibai.com/git/git_basic_concepts.html 零零...

  • 入门级文章足够

    http://www.runoob.com/git/git-basic-operations.html https...

  • Git basic

    clone the project go into/return back the project list th...

  • GIt Basic

    ssh-keygen 在本地电脑中中生成钥匙 打开公钥id-rsa.pub ,将公钥copy到git网站的SSH ...

网友评论

      本文标题:GIt Basic

      本文链接:https://www.haomeiwen.com/subject/szfghxtx.html