git

北慕城南 提交于 2019-12-06 13:12:52

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!