zoukankan      html  css  js  c++  java
  • 【环境配置】配置git

    版权声明:本文为博主原创文章。未经博主同意不得转载。 https://blog.csdn.net/manoel/article/details/37736005

    ssh和git的安装

    (1) git是基于ssh协议的,首先安装ssh。

    sudo apt-get install openssh-server openssh-client

    (2)安装好ssh后,启动ssh服务。
    sudo /etc/init.d/ssh restart

    (3) 安装git
    sudo apt-get install git-core

    (4) 生成本地ssh公钥
    ssh-keygen -C 'your emaildress' -t rsa
    比如:
    ssh-keygen -C 'sunguowei@gmail.com' -t rsa
    会在用户文件夹~/.ssh/下建立对应的密钥文件

    (5) 上传公钥至github
    在账户的profile里,选择SSH KEYS 选项,然后选择Add SSH Key,将~/.ssh/id_rsa.pub中的内容复制进去,保存。


    上传成功后,会收到确认邮件。

    (6)此时,git就已经配置成功了。接下来进行一些简单的配置。



    git的配置
    (1) 配置user信息
    git config --global user.name "Your Real Name"
    git config --global user.email you@email.address

    (2) 配置git颜色
    git config --global color.status auto
    git config --global color.diff auto
    git config --global color.branch auto
    git config --global color.interactive auto

    git的命令
    git branch 查看本地全部分支
    git status 查看当前状态 
    git commit 提交 
    git branch -a 查看全部的分支
    git branch -r 查看本地全部分支
    git commit -am "init" 提交而且加凝视 
    git remote add origin git@192.168.1.119:ndshow
    git push origin master 将文件给推到server上 
    git remote show origin 显示远程库origin里的资源 
    git push origin master:develop
    git push origin master:hb-dev 将本地库与server上的库进行关联 
    git checkout --track origin/dev 切换到远程dev分支
    git branch -D master develop 删除本地库develop
    git checkout -b dev 建立一个新的本地分支dev
    git merge origin/dev 将分支dev与当前分支进行合并
    git checkout dev 切换到本地dev分支
    git remote show 查看远程库
    git add .
    git rm 文件名称(包含路径) 从git中删除指定文件
    git clone git://github.com/schacon/grit.git 从server上将代码给拉下来
    git config --list 看全部用户
    git ls-files 看已经被提交的
    git rm [file name] 删除一个文件
    git commit -a 提交当前repos的全部的改变
    git add [file name] 加入一个文件到git index
    git commit -v 当你用-v參数的时候能够看commit的差异
    git commit -m "This is the message describing the commit" 加入commit信息
    git commit -a -a是代表add,把全部的change加到git index里然后再commit
    git commit -a -v 一般提交命令
    git log 看你commit的日志
    git diff 查看尚未暂存的更新
    git rm a.a 移除文件(从暂存区和工作区中删除)
    git rm --cached a.a 移除文件(仅仅从暂存区中删除)
    git commit -m "remove" 移除文件(从Git中删除)
    git rm -f a.a 强行移除改动后文件(从暂存区和工作区中删除)
    git diff --cached 或 $ git diff --staged 查看尚未提交的更新
    git stash push 将文件给push到一个暂时空间中
    git stash pop 将文件从暂时空间pop下来
    git remote add origin git@github.com:username/Hello-World.git
    git push origin master 将本地项目给提交到server中
    git pull 本地与server端同步
    git push (远程仓库名) (分支名) 将本地分支推送到server上去
    git push origin serverfix:awesomebranch
    git fetch 相当于是从远程获取最新版本号到本地,不会自己主动merge
    git commit -a -m "log_message" (-a是提交全部改动。-m是加入log信息) 本地改动同步至server端
    git branch branch_0.1 master 从主分支master创建branch_0.1分支
    git branch -m branch_0.1 branch_1.0 将branch_0.1重命名为branch_1.0

    git checkout branch_1.0/master 切换到branch_1.0/master分支


    git push/pull缓慢的解决的方法

    /etc/ssh/ssh_config
    找到
    GSSAPIAuthentication no 这句话,将其凝视去掉就可以。


    过滤指定文件和文件夹

    在project的根文件夹下。创建.gitignore文件,在当中指定须要过滤的文件。

    *.gitignore
    *.iml
    .idea/
    target/



  • 相关阅读:
    轻量级分布式任务调度框架(二、LTS编译、打包、部署)
    轻量级分布式任务调度框架(一、LTS简介、特点、工作流程)
    MySQL数据库学习一
    Navicat 连接 SQL Server 数据库,报错 08001
    noVNC 遇到一个错误: Uncaught TypeError: Cannot read property 'forEach' of undefined
    加强自己VPS服务器安全的一次经历
    Python 编码错误的本质和解决方案
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'data' at line 1
    requests爬虫请求报错:UnicodeEncodeError: 'latin-1' codec can't encode character 'u2026' in position 30
    docker无法删除镜像,Error: No such container,附docker常用命令
  • 原文地址:https://www.cnblogs.com/mqxnongmin/p/10887194.html
Copyright © 2011-2022 走看看