GIt Basic

  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 将项目代码拉到本地。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1.git的安装 1.1 在Windows上安装Git msysgit是Windows版的Git,从https:/...
    落魂灬阅读 12,716评论 4 54
  • 1. 安装 Github 查看是否安装git: $ git config --global user.name "...
    Albert_Sun阅读 13,736评论 9 163
  • 就在春分这天,下了我在这个城市上学以来最大的一场雨。清晨,一阵惊雷把我拉回行程满满的世界。就这样,踏上了前往长城敬...
    半痕阅读 228评论 0 0
  • 一个人总要走陌生的路,看陌生的风景,听陌生的歌。 然后在某个不经意的瞬间你会发现, 原本费尽心机想要忘记的事情, ...
    音曼实验室阅读 441评论 0 0
  • 已时至深秋,前几日阴雨连连的天气今终停了。天似乎放晴,却也不是本该秋日里的天高云淡,即使这样,也好过那铅色的...
    傅清明阅读 394评论 3 3