码迷,mamicode.com
首页 > 编程语言 > 详细

java基础---->git的使用(一)

时间:2017-12-19 15:08:13      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:说明   sdn   origin   force   csv   没有   int   ref   osi   

  这里面记录一下git的使用,只是平时工作中遇到的一些问题的解决方案,不会涉及到git的一些基础概念及说明。人的天性便是这般凉薄,只要拿更好的来换,一定舍得。

 

Git的一些使用

一、在码云建立好仓库之后,想把本地已经写好的代码推送上去。

首先git init我们的项目:

huhx@Linux MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1
$ git init
Initialized empty Git repository in G:/Java/Go/program/2017-05-18/LearnPython1/.git/

 添加项目到本地的仓库:

huhx@Linux MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)
$ git add .

 提交代码到本地仓库:

huhx@Linux MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)
$ git commit -m commit python code
[master (root-commit) 4408093] commit python code
 110 files changed, 5905 insertions(+)
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/modules.xml
 create mode 100644 .idea/workspace.xml
 create mode 100644 LearnPython1.iml
 create mode 100644 datagram/connMysql.py
 create mode 100644 datagram/funUtils.py
 create mode 100644 datagram/huhx.py
 create mode 100644 file/bookdata.csv
 create mode 100644 file/huhx.png
 create mode 100644 file/huhx1.txt
 create mode 100644 file/huhx2.txt
 create mode 100644 file/log.txt
 create mode 100644 file/log1.txt
 create mode 100644 file/seach_button.png
 ......

与服务器的分支建立联系:

huhx@Linux MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)
$ git remote add origin https://gitee.com/huhx/pythonLearn.git

推送代码到远程仓库:

huhx@Linux MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)
$ git push -f origin master
Counting objects: 137, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (130/130), done.
Writing objects: 100% (137/137), 127.37 KiB | 1.46 MiB/s, done.
Total 137 (delta 1), reused 0 (delta 0)
To https://gitee.com/huhx/pythonLearn.git
 + 45c1fff...4408093 master -> master (forced update)

 注意上述的推送需要加-f参数,如果没有添加的话。会有如下的错误提示

huhx@Linux MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)
$ git push origin master
To https://gitee.com/huhx/pythonLearn.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to https://gitee.com/huhx/pythonLearn.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.

 

二、建立分支的一些基础操作,更新或者提交代码

整个的一个流程,可以如下的方式:

创建开发分支:
  git checkout huhx-dev 添加到git管理:
  git add . 提交到huhx
-dev本地仓库:
  git commit -m code 切换到master分支:
  git checkout master 从远程仓库更新代码:
  git pull 合并huhx
-dev分支:
  git merge huhx-dev 提交到本地的mater仓库:
  git commit
-m master commit 将本地的master代码提交到远程:
  git push origin master

关于分支创建、查看可以参考博客:http://blog.csdn.net/arkblue/article/details/9568249

 

友情链接

 

java基础---->git的使用(一)

标签:说明   sdn   origin   force   csv   没有   int   ref   osi   

原文地址:http://www.cnblogs.com/huhx/p/baseusejavagit1.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!