git 添加到環境變量

github 新增倉庫的後的提示html

…or create a new repository on the command line

echo "# top" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/liangkeno/top.git
git push -u origin master
…or push an existing repository from the command line

git remote add origin https://github.com/liangkeno/top.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.

  


 

1,找到安裝git的安裝目錄,C:\Program Files (x86)\Git\bin,win7在計算機屬性中添加路徑git

 

2,使用命令行添加,set PATH=%PATH%;C:\Program Files (x86)\Git\bingithub

 git 簡明教程:http://rogerdudler.github.io/git-guide/index.zh.htmlshell


安裝git的記錄json

1,配置git的全局參數,包括用戶名,郵箱地址,生產SSH公密鑰緩存

  1--,命令行設置用戶名,郵箱bash

      

git config --global user.name "username"
git config --global user.email "username@email.com"

  2,push.default參數主要是設置在執行push命令是的策略,主要的選項有如下幾個:ssh

  • nothing : Do not push anything
  • matching : Push all matching branches (default)
  • tracking : Push the current branch to whatever it is tracking
  • current : Push the current branch

這裏咱們手動設置成默認值:ide

git config --global push.default matching

  3,生成SSH key,在開始菜單中找到git bash並運行測試

$ssh-keygen -t rsa -C "username@email.com"

  此時會提示你輸入存儲key的文件名(我輸入github),並提示你輸入密碼與確認密碼(我這裏選擇不輸入),接着會生成連個文件名一個是公鑰與私鑰文件並存儲在C:\Users\***文件夾下:github,github.pub

  

  config文件,防止連接出現錯誤,代碼以下:

1 Host github.com
2   User git
3   Hostname ssh.github.com
4   PreferredAuthentications publickey
5   IdentityFile ~/.ssh/id_rsa
6   Port 443

 

  

  4,綁定本機git與github

    1--,打開github.pub公鑰文件,拷貝里面公鑰文本

    2--,登錄官網https://github.com/,建立帳號,進入設置,在SSH and GPG keys設置公鑰,

  5,打開git bash,輸入ssh git@github.com測試是否鏈接上github

  顯示以下信息即已經鏈接成功

$ ssh git@github.com
PTY allocation request failed on channel 0
Hi ****! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

  

  5,到此,既能夠使用本機上的git鏈接github上的repository了

 


 

  使用git Bash 添加文件從本地到github倉庫

  1,第一次更新到倉庫

    1--,初始化本地倉庫,

git init

    2--,更新到版本庫

$ git add *
//錯誤提示

warning: LF will be replaced by CRLF in package.json.
The file will have its original line endings in your working directory.

  解決方法:

$ git config --global core.autocrlf false

//更新全部文件
$ git add .

//更某個文件
$ git add 文件名

//更某個目錄
$ git add 目錄名/

    此時只是把文件放置緩存區

    3--,添加註釋

$ git commit -m "相關說明"

    4--,關聯到遠程倉庫

$ git remote add origin git@github.com:yourname/yourgit.git

    5--,推送到遠程倉庫

$ git push -u origin master

  2,再次更新到倉庫,使用 add>>commit>>push origin master 便可

 

 

 git add .

error:   filename too long

 git config --global core.longpaths true

   3,把遠程更新到本地倉庫

   下載遠程到本地 :git fetch origin master

   合併遠程到本地:git merge origin/master

相關文章
相關標籤/搜索