關於git在windows的一些配置和學習

2021-09-25 19:21:10 字數 2403 閱讀 4977

基礎配置

想撤銷檔案更改或是回退到之前版本

其他命令

關聯自己的github庫

建立ssh key

在使用者主目錄下,看看有沒有.ssh目錄,如果有,再看看這個目錄下有沒有id_rsa和id_rsa.pub這兩個檔案,如果已經有了,可直接跳到下一步。如果沒有,開啟shell(windows下開啟git bash),建立ssh key:ssh-keygen -t rsa -c "***@example.com"

主目錄裡找到.ssh目錄,裡面有id_rsa和id_rsa.pub兩個檔案,這兩個就是ssh key的秘鑰對,id_rsa是私鑰,不能洩露出去,id_rsa.pub是公鑰,可以放心地告訴任何人。

登陸github,開啟「account settings」,「ssh keys」頁面,填上任意title,在key文字框裡貼上id_rsa.pub檔案的內容

使用本地的git bash遠端關聯git remote add origingit push -u origin master推上自己的倉庫內容

git clone https://...............也可轉殖別人的倉庫到本地

git branch檢視當前所有分支

$ git branch

* dev

master

合併時遇到的問題
$ git merge feature1

auto-merging readme.txt

conflict (content): merge conflict in readme.txt

automatic merge failed; fix conflicts and then commit the result.

git is a distributed version control system.

git is free software distributed under the gpl.

git has a mutable index called stage.

git tracks changes of files.

<<<<<<< head

creating a new branch is quick & ******.

*****==

creating a new branch is quick and ******.

>>>>>>> feature1

>

$ git add readme.txt 

$ git commit -m "conflict fixed"

[master cf810e4] conflict fixed

$ git log --graph --pretty=oneline --abbrev-commit

* cf810e4 (head -> master) conflict fixed

|\

| * 14096d0 (feature1) and ******

* | 5dc6824 & ******

|/

git教

windows關於Git工具的使用

第一步 1 git init 這個命令會在當前目錄下建立乙個.git資料夾。第二步 1 git add.這個命令會把當前路徑下的所有檔案,新增到待上傳的檔案列表中。第三步 1 git commit m xx 1 git remote add origin https 使用者名稱 github專案名....

在Windows上安裝Git

安裝完成後,在開始選單裡找到 git git bash 蹦出乙個類似命令列視窗的東西,就說明git安裝成功!安裝完成後,還需要最後一步設定,在命令列輸入 git config global user.name your name git config global user.email email ...

git教程(在Windows上安裝Git)

安裝完成後,在開始選單裡找到 git git bash 蹦出乙個類似命令列視窗的東西,就說明git安裝成功!安裝完成後,還需要最後一步設定,在命令列輸入 git config global user.name your name git config global user.email email ...