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
    
  • 相关阅读:
    结构层HTML + 表现层CSS
    移动端:项目实战
    移动端:开发技巧
    两个对象数组,把其中相同的name的before相加,不同的对象添加到数组里
    js中遍历数组和遍历对象
    css学习笔记一
    Angular2父子组件数据传递之@ViewChild获取子组件详解
    css知识点总结
    js中的apply,call,arguments,callee,caller详解
    javascript中的排序
  • 原文地址:https://www.cnblogs.com/coser/p/3505419.html
Copyright © 2011-2022 走看看