git学习心得

本文详细记录了使用Git进行版本控制的一系列操作,包括生成SSH key,配置端口,提交代码,创建并切换分支,解决远程分支冲突。通过实例展示了如何在本地和远程仓库之间进行交互,如`git add`,`git commit`,`git push`等,以及在遇到冲突时如何使用`git pull`和删除远程分支来解决问题。
摘要由CSDN通过智能技术生成

   git是一款十分有用的版本控制软件,程序员必备。

http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013743256916071d599b3aed534aaab22a0db6c4e07fd0000


1.生成key 

 ssh-keygen -t rsa 
将生成的位于.ssh下的pub文件cat后,复制到git的ssh key当中。


2.在.ssh目录下2新建config,加入port XXXX (端口)


3.修改config权限 chmod 600


4.git pull origin master 该步骤要位于当前工作空间之下

当前工作空间:

F:\Program Files\Git\guoxungit\hearthdap-front



//取消更改 回滚到上次状态

1.git reset --hard

2.git reset --hard head^^ //回滚到上上次 ……head~1//回滚到上一次版本


一.提交代码操作流程:

1.查看当前本地分支 git branch


2.查看网络分支 git branch -a


3.添加本地分支 git branch guoxun


4.切换到本地分支 git checkout guoxun


5.git status 查看当前文件状态


6.文件的三种状态 只有暂存区域的文件(即:文件状态为“Changes to be committed”)才会被提交
http://phplaber.iteye.com/blog/1699926
除了之前的“Changes to be committed”状态,现在又多了一条“Changes not staged for commit”状态,表明文件已经修改,但是还没有放入暂存区域,也就是没生成快照。如果现在进行commit操作,只是将修改之前的文件快照提交到了git目录,一定记住:只有暂存区域的文件(即:文件状态为“Changes to be committed”)才会被提交。正如提示,通过“git add README.txt”命令将已修改文件更新到暂存区域中,如果想撤销修改,可以使用“git checkout -- README.txt”命令


7.git add application/ 将以application开头的文件设为Changes to be committed状态


8.git reset HEAD .idea 将以.idea开头的文件从change to be committed状态回退到前一个状态


9.git log 查看近期修改日志


10.git commit -m "add index of help" 提交


11.git push origin guoxun 把修改提交到分支上


操作记录:



admin@guoxun MINGW64 /guoxungit (master)
$ git branch
* master


admin@guoxun MINGW64 /guoxungit (master)
$ git checkout


admin@guoxun MINGW64 /guoxungit (master)
$ git branch -a
* master
  remotes/origin/master


admin@guoxun MINGW64 /guoxungit (master)
$ git branch guoxun


admin@guoxun MINGW64 /guoxungit (master)
$ git branch
  guoxun
* master


admin@guoxun MINGW64 /guoxungit (master)
$ git checkout test
error: pathspec 'test' did not match any file(s) known to git.


admin@guoxun MINGW64 /guoxungit (master)
$ git checkout guoxun
Switched to branch 'guoxun'


admin@guoxun MINGW64 /guoxungit (guoxun)
$ git push origin guoxun
Total 0 (delta 0), reused 0 (delta 0)
To git@git.qyidea.com:hui.chen/hearthdap-front.git
 * [new branch]      guoxun -> guoxun


admin@guoxun MINGW64 /guoxungit (guoxun)
$ ls
application/  hearthdap-front/  spacerscoringcrispr-code/
assets/       index.php         system/
download/     license.txt       user_guide/


admin@guoxun MINGW64 /guoxungit (guoxun)
$ cd hearth-front
bash: cd: hearth-front: No such file or directory


admin@guoxun MINGW64 /guoxungit (guoxun)
$ cd hearthdap-front/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (master)
$ ls
application/  CodeIgniter-3.0.2.zip  index.html  license.txt  user_guide/
assets/       download/              index.php   system/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (master)
$ git branch guoxun


admin@guoxun MINGW64 /guoxungit/hearthdap-front (master)
$ git checkout guoxun
A       .idea/vcs.xml
M       application/libraries/Cipredis.php
Switched to branch 'guoxun'


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git push origin guoxun
Everything up-to-date


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git commit
Aborting commit due to empty commit message.


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git commit -m "help

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值