zoukankan      html  css  js  c++  java
  • Git常用命令

    Create remote repo

    pwd:/Users/zhanglx/workspace/gittest/
    git init --bare
    

    Clone repo from remote repo

    git clone /Users/zhanglx/workspace/gittest/
    

    Init a local git repo and add a remote

    This is equal to "Clone"

    mkdir myrepo
    cd myrepo/
    git init
    git remote add origin /Users/zhanglx/workspace/gittest/
    

    New branch and switch to this branch

    git branch test
    git checkout test
    

    Type git branch to check which branch you are working on.

    Add, modify, commit, reset and checkout history

    Git文件状态

    Git文件的状态分为untracked和tracked, untracked文件是指新建的文件,尚未被git管理起来。

    tracked又分为三种状态:

    已提交(committed),已修改(modified)和已暂存(staged)。已提交表示文件已被安全地保存在本地数据库中了;已修改表示修改了某个文件,但没有提交保存;已暂存表示把已修改的文件放在下次提交时要保存的清单中。

    Github

    git remote show origin 查看相关信息 git push origin master 将commit的代码,push到github上。 git pull origin master 将github上的代码,update到本地。

    Delete

    git delete file 然后commit的,将无法恢复。 rm file, 可以通过git checkout -- file进行恢复。 git rm --cached file,只是在缓存中删除,

    恢复更改的文件 git checkout — //未git add的文件

    git reset HEAD //已经git add的文件,可以用这个取消add,然后用上一条命令恢复

    Push master branch of locale repo to remote origin

    git push origin master

    Pull (if there are some conflicts, git will call git merge automatically)

    git pull origin master

    创建SSH key

    ssh-keygen
    生成的SSH key文件保存在中~/.ssh/id_rsa.pub
    

    添加SSH key到github

    接着拷贝.ssh/id_rsa.pub文件内的所以内容
    打开github帐号管理中的添加SSH key界面的步骤如下:
    1. 登录github
    2. 点击右上方的Accounting settings图标
    3. 选择 SSH key
    4. 点击 Add SSH key
    
  • 相关阅读:
    http协议
    三次握手四次挥手的原理
    mmap
    I/O多路复用之poll
    I/O多路转接之select
    自旋锁、文件锁、大内核锁
    网络基础(一)
    线程同步之(信号量)
    进程与线程的简单理解
    内存溢出——程序员必备网站
  • 原文地址:https://www.cnblogs.com/coser/p/3505419.html
Copyright © 2011-2022 走看看