日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

eclipse查看git地址_gitamp;github的入门实战

發布時間:2023/12/2 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 eclipse查看git地址_gitamp;github的入门实战 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、Git概述

(1)定義

Git是目前世界上最先進的分布式版本控制系統。

(2)能干什么?

解決沖突、管理權限、代碼備份、協同開發、版本還原、歷史追查、版本記錄、分支管理、代碼審查

(3)集中管理型版本管理

經典的集中管理型(CVS、VSS、SVN)

特點:

  • 實現了大部分開發中對版本管理的需求
  • 結構簡單,上手容易。

依然存在的問題

1、版本管理的服務器一旦崩潰,硬盤損壞,代碼如何恢復?2、程序員上傳到服務器的代碼要求是完整版本,但是程序員開發過程中想做小版本的管理,以便追溯查詢,怎么辦?3、系統正在上線運行,時不時還要修改bug,要增加好幾個功能要幾個月,如何管理幾個版本?4、如何管理一個分布在世界各地、互不相識的大型開發團隊?

(4)Git如何解決

Git 工具

1、命令行工具:Git for windows
下載地址:https://git-for-windows.github.io/
2、 操作系統中可視化工具:TortoiseGit
下載地址: Windows Shell Interface to Git
3、 Eclipse插件: Egit
Eclipse自帶,插件市場搜索最新版
4、 GitHub網站
Build software better, together

二、Git軟件

1、git環境下載安裝

安裝完成后,還需要最后一步設置,在命令行輸入如下:

Git是分布式版本控制系統,所以需要填寫用戶名和郵箱作為一個標識。
C:Usersadmin路徑下的.gitconfig文件里面可以看到
--global 表示全局屬性,所有的git項目都會共用屬性

操作:

mrman

文件自動產生

2、Git軟件操作

(1)理解工作目錄,暫存區,本地倉庫

  • 工作區(Working Directory):就是你電腦本地硬盤目錄
  • 本地庫(Repository):工作區有個隱藏目錄.git,它就是Git的本地版本庫
  • 暫存區(stage):一般存放在"git目錄"下的index文件(.git/index)中,所以我們把暫存區有時也叫作索引(index)。

(2)操作:

創建項目文件夾設置文件夾屬性

創建本地版本倉庫

mrman@DESKTOP-QH8S7FP MINGW64 /e $ git init //初始化一個倉庫,執行命令“ git init” Initialized empty Git repository in E:/.git/mrman@DESKTOP-QH8S7FP MINGW64 /e (master)

多出來一個文件:

提交文件

  • 新建文件,名為“hello.txt”

hello.txt編輯內容:

111111111
  • 輸入命令:git add 文件名,將文件添加到暫存區(沒有放在倉庫)
mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git add hello.txtmrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git status //查看狀態 On branch masterInitial commitChanges to be committed:(use "git rm --cached <file>..." to unstage)new file: hello.txtUntracked files:(use "git add <file>..." to include in what will be committed)$RECYCLE.BIN/Linux/ZJZL/kinggsoft/qqpcmgr_docpro/qycache/mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $

如圖所示:

輸入命令:git commit 提交文件到本地庫

mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git commit [master (root-commit) 1a89c3f] create 11 file changed, 1 insertion(+)create mode 100644 hello.txt

若想再次提交,可以這樣操作,先修改hello.txt

mrman

mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git commit warning: LF will be replaced by CRLF in hello.txt. The file will have its original line endings in your working directory. [master warning: LF will be replaced by CRLF in hello.txt. The file will have its original line endings in your working directory. 9696331] updata 2 warning: LF will be replaced by CRLF in hello.txt. The file will have its original line endings in your working directory.1 file changed, 2 insertions(+), 1 deletion(-)mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $//查看提交文件有哪些 mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git log commit 96963315b2c39a52a4f97bf2bd79551d2226d87c Author: gitacct_pm <mrman8868@163.com> Date: Mon May 11 11:34:49 2020 +0800updata 2commit 1a89c3f50f37f89a717ca116c968bd229ce4bf6d Author: gitacct_pm <mrman8868@163.com> Date: Mon May 11 11:26:15 2020 +0800create 1查看文件提交記錄 //行查看(查看簡易信息 ) mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git log --pretty=oneline 96963315b2c39a52a4f97bf2bd79551d2226d87c updata 2 1a89c3f50f37f89a717ca116c968bd229ce4bf6d create 1回退歷史 //回退到上一次提交 mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git reset --hard HEAD^ HEAD is now at 1a89c3f create 1//再次查看,發現updata 2沒有了 mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git log --pretty=oneline 1a89c3f50f37f89a717ca116c968bd229ce4bf6d create 1版本穿越 //查看歷史記錄的版本號 $ git reflog 1a89c3f HEAD@{0}: reset: moving to HEAD^ 9696331 HEAD@{1}: commit: updata 2 1a89c3f HEAD@{2}: commit (initial): create 1//恢復 updata 2 mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git reset --hard 9696331 HEAD is now at 9696331 updata 2//再次查看,發現有updata 2 mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git log --pretty=oneline 96963315b2c39a52a4f97bf2bd79551d2226d87c updata 2 1a89c3f50f37f89a717ca116c968bd229ce4bf6d create 1

誤刪除項目文件夾中的hello.txt文本?

輸入命令:git checkout 文件名,此時,倉庫中的文件依然存在,所以可以從本地倉庫中還原文件

mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git checkout hello.txt

若想刪除后的hello.txt文件,想增加到緩沖區里面

mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git add hello.txtmrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git status On branch master Changes to be committed:(use "git reset HEAD <file>..." to unstage)modified: hello.txtUntracked files:(use "git add <file>..." to include in what will be committed)$RECYCLE.BIN/Linux/ZJZL/kinggsoft/qqpcmgr_docpro/qycache/

若想知道曾經做過哪些操作,不管是增刪改查,可以這樣做

mrman

(3)系統上線了,但是產品經理又提了新的需求,評估一下工期要兩個月,但是同時系統正在上線運行,時不時還要修改bug,如何管理幾個版本?

創建分支

//創建分支

切換分支

//切換名為“branchA”分支 mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git checkout branchA Switched to branch 'branchA'//創建word.txt文件寫數據:word mrman@DESKTOP-QH8S7FP MINGW64 /e (branchA) $ echo "word" >> word.txt

創建word.txt文件

//創建新的,這個文件存放在倉庫里面 mrman@DESKTOP-QH8S7FP MINGW64 /e (branchA) $ git add word.txt warning: LF will be replaced by CRLF in word.txt. The file will have its original line endings in your working directory.mrman@DESKTOP-QH8S7FP MINGW64 /e (branchA) $ git commit -m 'create1' [branchA ff28a03] create1 warning: LF will be replaced by CRLF in word.txt. The file will have its original line endings in your working directory.1 file changed, 1 insertion(+)create mode 100644 word.txt

切換主線master

mrman@DESKTOP-QH8S7FP MINGW64 /e (branchA) $ git checkout master Switched to branch 'master'

發現開始創建的work.txt文件沒有了

切換回來branchA

mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git checkout branchA Switched to branch 'branchA'發現開始創建的work.txt文件有了

合并分支(以master為主)

//切換主線master mrman@DESKTOP-QH8S7FP MINGW64 /e (branchA) $ git checkout master Switched to branch 'master'//合并分支 mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git merge branchA Updating 9696331..ff28a03 Fast-forwardword.txt | 1 +1 file changed, 1 insertion(+)create mode 100644 word.txt

mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git checkout master Already on 'master' mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ vim word.txt123 wordmrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git add word.txtmrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git commit -m 'add 123' [master f01119e] add 1231 file changed, 1 insertion(+), 1 deletion(-)

三、GitHub

1、GitHub是什么

HUB是一個多端口的轉發器,在以HUB為中心設備時,即使網絡中某條線路產生了故障,并不影響其它線路的工作。
GitHub是一個Git項目托管網站,主要提供基于Git的版本托管服務

網址:https://github.com/

注冊賬號的注意事項:

較長時間不使用有可能被Github凍結賬號。請登錄其客服頁面https://github.com/contact,填寫賬號恢復申請。

首先,登錄自己的github:輸入郵箱地址+密碼

登錄github

驗證代碼編碼

github驗證碼

首先:創建項目工程

之后,我們需要在git的窗口操作命令,先執行:git reflog

mrman

增加遠程地址,一般直接用origin作代號,也可以自定義,另需要執行自己的github創建倉庫生成的遠程:HTTPS的遠程地址。執行命令:

//告訴遠程倉庫地址

推送到遠程庫

mrman@DESKTOP-QH8S7FP MINGW64 /e (master) $ git push origin master

登錄口

輸入郵箱口

彈出窗口,輸入密碼:

加載這些信息:

$

說明連上了,區自己的github查看,如圖所示:

2、從GitHub上克隆(復制)一個項目

(1)在自己github的文件數據或項目克隆到本地指定的文件目錄下(通俗說下載到本地磁盤),可以這樣操作

執行命令如下:

mrman

查看文件:

(2)若想要在本地磁盤文件做更改,可以這樣執行操作

//先進入pt文件目錄下

查看:

(3)每次輸密碼很煩篇

先創建ssh密鑰

mrman@DESKTOP-QH8S7FP MINGW64 ~/Desktop $ ssh-keygen -t rsa -C mrman10086@163.comGenerating public/private rsa key pair. Enter file in which to save the key (/c/Users/mrman/.ssh/id_rsa): Created directory '/c/Users/mrman/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/mrman/.ssh/id_rsa. Your public key has been saved in /c/Users/mrman/.ssh/id_rsa.pub. The key fingerprint is: SHA256:YswQszo3grw+yfXvMhZ5gTR7mCf9ll3PGCaOX3ObucY mrman10086@163.com The key's randomart image is: +---[RSA 2048]----+ | o | | * | | + B | |.. . X = . + | |..+ o X S = + = | | .= = o = o + + | |..o . o . . . + +| |.+ = . E | | .. . =o ...| +----[SHA256]-----+

登錄Github后,右上角點擊setting

在左側菜單中選擇SSH and GPG keys, 在右邊點擊New SSH key

Title隨便寫,Key 把之前id_rsa.pub的內容復制進去,點擊Add SSH key,設置ssh key 完成。

查看:

再次提交:

mrman@DESKTOP-QH8S7FP MINGW64 /e/.git/repository/pt (master) $ git add word.txtmrman@DESKTOP-QH8S7FP MINGW64 /e/.git/repository/pt (master) $ git commit -m "add ssh" [master 97c8f26] add ssh1 file changed, 1 insertion(+), 1 deletion(-)mrman@DESKTOP-QH8S7FP MINGW64 /e/.git/repository/pt (master) $ git remote add originssh git@github.com:Peng8868sky/Project20200512.gitmrman@DESKTOP-QH8S7FP MINGW64 /e/.git/repository/pt (master) $ git push originssh masterThe authenticity of host 'github.com (52.74.223.119)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts. Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 286 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@github.com:Peng8868sky/Project20200512.git98376c8..97c8f26 master -> master

查看:

(4)代碼提交

先在idea根據登錄自己的github

后如下操作:

查看已經提交進來了

總結

以上是生活随笔為你收集整理的eclipse查看git地址_gitamp;github的入门实战的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。