zoukankan      html  css  js  c++  java
  • Git

    一,找到git仓库:finder打开项目,找到隐藏文件.git

    终端:Mac显示隐藏文件:defaults write com.apple.finder AppleShowAllFiles YES,强制退出finder,重新打开finder.

    如果项目没有隐藏的Git文件夹:

    1,打开终端,cd 工程目录,

    2,指令:git Init

    3,git add .//点,第一次提交的时候需要三四步。

    4,git commit -m "Initial commit"

    在打开就有git文件夹了

    二,提交代码,Xcode source control 里面,commit,

    提交之前回滚之前代码discard all,或者discard 单个文件

    三,提交之后回滚之前版本:

    终端,cd 工程目录.

    git reflog //查看提交日志,前面是版本号

    git reset --hard 版本号//即可回到之前版本,hard强制执行,可多次执行,回到不同的版本

    扩展:git config alias.rst 'reset --hard'//增加别名:用rst 取代reset --hard,换git文件夹的时候即换项目时候,失效。

     四,上传到gitHub:

    1:创建SSH Key

    ozil:tmp mesut$ cd ~
    ozil:~ mesut$ pwd
    /Users/mesut
    ozil:~ mesut$ cd .ssh
    -bash: cd: .ssh: No such file or directory
    ozil:~ mesut$ 

    进入当前的用户目录,波浪线表示的是当前目录。判断是否已经安装了.ssh,避免默认安装会覆盖之前安装的。明显当前目录没有该文件

    执行创建 ssh key

    ssh-keygen -t rsa -C youremail@example.com(你的Github登陆名)

    接着都是回车,选择默认的目录,默认的密码即可

    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/mesut/.ssh/id_rsa):     
    Created directory '/Users/mesut/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /Users/mesut/.ssh/id_rsa.
    Your public key has been saved in /Users/mesut/.ssh/id_rsa.pub.

    接着可以在用户主目录里找到.ssh目录,里面有id_rsaid_rsa.pub两个文件,这两个就是SSH Key的秘钥对

    ozil:~ mesut$ cd .ssh
    ozil:.ssh mesut$ ls
    id_rsa		id_rsa.pub

    2:在Github设置ssh key

    登陆Github, “Settings”->SSH keys->Add SSH key

    title:可以顺便填名字

    key:在Key文本框里粘贴id_rsa.pub文件的内容

    点击add key 配置完成

    3:测试本地是否和Github连接上

    ozil:.ssh mesut$ ssh -T git@github.com
    The authenticity of host 'github.com (xxx)' can't be established.
    RSA key fingerprint is xxx.
    Are you sure you want to continue connecting (yes/no)? yes
    第一次链接Github,会有一个确认,需要你确认GitHub的Key的指纹信息是否真的来自GitHub的服务器,输入yes回车即可。

    Warning: Permanently added 'github.com,xxx' (RSA) to the list of known hosts.Hi tanchongshi! You've successfully authenticated, but GitHub does not provide shell access.

    4.使用git在本地建立的项目更新到Github

    首先在本地初始化一个git仓库

    由于之前没有配置用户名,所以首次commit会有提示,自动建立

    设置方式

    $ git config --global user.name Your Name
    $ git config --global user.email email@example.com
    为了把本地库推到远程服务器,首先需要在Github上面也建一个项目

    在Repository name填上我们的项目名字,description随便填,别的默认。

    然后会生成项目

    然后把远程项目和本地库关联:cd 到.git 目录

    ozil:hellogithub mesut$ git remote add origin git@github.com:tanchongshi/hellogithub.git
    ozil:hellogithub mesut$ git push -u origin master
    Warning: Permanently added the RSA host key for IP address 'XXX' to the list of known hosts.
    Counting objects: 3, done.
    Writing objects: 100% (3/3), 217 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To git@github.com:tanchongshi/hellogithub.git
     * [new branch]      master -> master
    Branch master set up to track remote branch master from origin.
    完成
    配置之后,提交新项目到github 只要cd 进入目录,1,git init 2,git add .3,将github里面新建项目中复制

    echo "# Location" >> README.md
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin https://github.com/YQL539/Location.git
    git push -u origin master  

    复制到shell里面,点击enter即可提交到github

  • 相关阅读:
    使用react hook做一个小型完整项目(包括二级路由,动态路由,redux,tab切换,列表跳详情,登录, 守卫)
    项目实战【vue,react,微信小程序】(1705E)
    Vue(1706E)
    加入购物车动画(css)
    React从入门到精通(1704B)
    React(1702H)文章管理-cms系统
    React(1702H)文件上传和分页查找
    React (1702H) 点击复制、滚动条、图形验证码、ridis、密码rsa加密、token、发邮件、文件上传、sql语句
    位图算法
    def跨域+jwt
  • 原文地址:https://www.cnblogs.com/yangqinglong/p/5587448.html
Copyright © 2011-2022 走看看