• 使用Githua管理代码


    原创博客:转载请标明出处:http://www.cnblogs.com/zxouxuewei/

    1、安装配置git服务器
          a、安装ssh,因为git是基于ssh协议的,所以必须先装ssh:

    sudo apt-get install openssh-server openssh-client

        b, 安装好ssh后,启动ssh服务:

    sudo /etc/init.d/ssh restart     

         c、安装git服务器:

     sudo apt-get install git-core

    Checking for existing SSH keys

    (1) Open Terminal.

    (2) Enter ls -al ~/.ssh to see if existing SSH keys are present:

    ls -al ~/.ssh
    #Lists the files in your .ssh directory, if they exist

    (3) Check the directory listing to see if you already have a public SSH key.

    出现 github 为私钥,github.pub为公钥。

    Generating a new SSH key

    (1) Open Terminal.

    (2) Paste the text below, substituting in your GitHub email address.

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    # Creates a new ssh key, using the provided email as a label
    **Generating public/private rsa key pair.**

    (3) When you’re prompted to “Enter a file in which to save the key,” press Enter. This accepts the default file location.

    Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

    (4) At the prompt, type a secure passphrase. For more information, see “Working with SSH key passphrases”.

    Enter passphrase (empty for no passphrase): [Type a passphrase]
    Enter same passphrase again: [Type passphrase again]

    Adding your SSH key to the ssh-agent

    Before adding a new SSH key to the ssh-agent, you should have checked for existing SSH keys and generated a new SSH key.

    (1) Ensure ssh-agent is enabled:

    # start the ssh-agent in the background
    eval "$(ssh-agent -s)"
    Agent pid 59566

    (2) Add your SSH key to the ssh-agent. If you used an existing SSH key rather than generating a new SSH key, you’ll need to replace id_rsa in the command with the name of your existing private key file.

    $ ssh-add ~/.ssh/id_rsa

    (3)Add the SSH key to your GitHub

    1. Copy the SSH key to your clipboard.

    If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don’t add any newlines or whitespace.

    $ sudo apt-get install xclip
    # Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
    $ xclip -sel clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard 

    Tip: If xclip isn’t working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

    在账户的profile里,选择SSH KEYS 选项,然后Add SSH Key,将~/.ssh/id_rsa.pub中的内容复制进去,上传成功后,会收到确认邮件。 可以使用ssh -v git@github.com命令来测试链接是否畅通。

    2.In the top right corner of any page, click your profile photo, then click Settings.

    3.In the user settings sidebar, click SSH and GPG keys

    4.Click New SSH key.

    5.In the “Title” field, add a descriptive label for the new key. For example, if you’re using a personal Mac, you might call this key “Personal MacBook Air”.
    The key field

    6.Paste your key into the “Key” field.

    7.Click Add SSH key.

    8.Confirm the action by entering your GitHub password.

    设置账户信息

    git config --global user.name “lukeyan”
    git config --global user.email xxx@gmail.com

    设置成功后,用Terminal用ssh命令访问GitHub,会显示一条认证成功的消息并退出。

    ssh -T git@github.com

    执行后提示:

    
    

    经过以上几步设置就可以直接使用git命令访问github的代码仓库了。

    3.提交代码至GitHub

    首先,在github.com上创建一个新的repo,根据情况加上适当的.gitignore,LICENSE等,然后提交本地代码至github

    git init
    git status
    git add ./

    git commit -m "init files"
    git remote add origin git@github.com:yourgithubname/yourrepositoryname.git 

    git push -u origin master

    3.提交代码至SVN

    1.显示SVN文件与目录:
        svn ls https://192.168.1.68/svn/Probot/ZhouXueWei/ --username ZhouXueWei
    
    2.CheckOut程序
        svn co https://192.168.1.68/svn/Probot/ZhouXueWei/ /home/zxwbot/commend/
    
    3.svn更新代码
         svn up keysi_package/
    
    4.添加代码
        svn add ./test
    
    5.上传代码
        svn commit -m "test"
    
    6.删除远程文件
        svn delete update
        svn commit -m "Deleted file 'update'."
  • 相关阅读:
    React.render和reactDom.render的区别
    CSS中position的4种定位详解
    React.js入门必须知道的那些事
    JS处理事件小技巧
    React.js深入学习详细解析
    React.js实现原生js拖拽效果及思考
    Linux ./configure && make && make install 编译安装和卸载
    Redis set集合结构及命令详解
    Redis数据过期策略
    Redis TTL命令
  • 原文地址:https://www.cnblogs.com/zxouxuewei/p/6080632.html
Copyright © 2020-2023  润新知