首页 > 其他 > 详细

git

时间:2019-12-05 09:06:53      阅读:83      评论:0      收藏:0      [点我收藏+]

git

1.初始化仓库

git init

2.远程操作

2.1.添加远程链接

git remote  add   {别名,可代替url}      url

eg:  
    git remote add   pb  git://github.com/paulboone/ticgit.git

2.2.查看远程库

git  remote        #查看远程库(只能看到自定义的别名)

git   remote  -v   #查看远程库并列出详细信息

2.3.删除远程库

git  remote  rm  [别名]

2.4.从远程库获取更新并自动merge

git  pull    <origin[远程库别名]>  <master[本地库]>
==> 
    git fetch ;
    git merge;

2.5.将本地更新发送到远程库中

git push  <origin(别名)>   <master>

3.分支操作

3.1查看分支

git branch (-a)  查看本地分支(和远端分支)

3.2创建本地分支

git branch 分支名

3.3切换分支

git checkout 分支名

4.常用命令

git commit -am  filename   "....."    ==>    git add  filename;  git commit  -m   "....";

git rm <file>

git rm -f <file>

git rm --cached <file>

git rm   -r  <filepath>  

git mv  oldfile   newfile

4.1 代码回滚

git log   #获取commit后面的提交版本号
        commit 09921c2b40eec00e6518d644eee9488335832989
        Author: jfxugithub <fxujunfeng@foxmail.com>
        Date:   Thu Nov 15 11:39:54 2018 +0800

            修改bug

        commit 62b4cd6e4a4fe426f4a91183935b19b4cb348475
        Merge: 70940d0 6c786de
        Author: jfxugithub <fxujunfeng@foxmail.com>
        Date:   Thu Nov 15 11:25:55 2018 +0800

            Merge branch ‘master‘ of github.com:jfxugithub/gittest

git reset --hard  62b4cd6e4a4fe426f4a91183935b19b4cb348475  #代码回退到之前的状态

5.修改git基本信息

$ git config --list

user.email=fxujunfeng@foxmail.com
user.name=fionns
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.fionn.url=git@gitee.com:fionns/KnowYou.git
remote.fionn.fetch=+refs/heads/*:refs/remotes/fionn/*

# 修改git提交用户的名字
$git config --global user.name fionns

git

原文:https://www.cnblogs.com/jfxu/p/11986655.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!