搜尋
首頁後端開發php教程GIT在Linux上的安装和使用简介,gitlinux安装简介_PHP教程

GIT在Linux上的安装和使用简介,gitlinux安装简介

<span>GIT在Linux上的安装和使用简介

解压后切换到其目录
$ tar xvfj git</span>-1.7.6.tar.<span>bz2
$ cd git</span>-1.7.6<span>
 
使用默认配置进行安装,如果想修改配置,可以使用 </span>./configure --<span>help 来获取帮助
 
$ </span>./<span>configure
$ make
$ make install
 
</span>2<span>、初始化配置
GIT默认安装在 </span>/usr/local/<span>bin ,安装之后可以验证一下是否安装好
 
$ whereis git
git</span>: /usr/local/bin/<span>git
$ git  </span>--<span>version
git version </span>1.7.6<span>
$ git  </span>--<span>help
 
首先需要指定用户名和电子邮件地址
 
$ git config  </span>--<span>global</span> user.<span>name &ldquo;GIT Admin&rdquo;
$ git config  </span>--<span>global</span> user.emal obugs.net@gmail.<span>com
 
再验证一下配置信息
  www</span>.2cto.<span>com  
$ git config  </span>--<span>list</span><span>
user</span>.name=<span>GIT Admin
user</span>.email=obugs.net@gmail.<span>com
core</span>.repositoryformatversion=0<span>
core</span>.filemode=<span>true</span><span>
core</span>.bare=<span>false</span><span>
core</span>.logallrefupdates=<span>true</span><span>
 
其实这些配置是存放在个人主目录下的 </span>.<span>gitconfig 文件中的
 
$ cat </span>~/.<span>gitconfig
[user]
name </span>=<span> GIT Admin
email </span>= obugs.net@gmail.<span>com
 
</span>3<span>、建立工程
本地存储的任何一个目录都可以建立GIT工程,如果已有工程位于 </span>/home/obugs/projects/<span>orangebugs 目录,就可以把这目录定义为GIT工程
$ cd </span>/home/obugs/projects/<span>orangebugs
$ git init
Initialized </span><span>empty</span> Git repository in /home/obugs/projects/orangebugs/.git/<span>
 
这样就建立了一个名为 </span>.<span>git 的文件夹,这就是GIT用来存储信息和跟踪改动的文件夹。
  www</span>.2cto.<span>com  
$ ls </span>-altr .<span>git
total </span>40<span>
drwxrwxr</span>-x 4 git git 4096 Aug 13 22:39<span> refs
drwxrwxr</span>-x 4 git git 4096 Aug 13 22:39<span> objects
drwxrwxr</span>-x 2 git git 4096 Aug 13 22:39<span> info
drwxrwxr</span>-x 2 git git 4096 Aug 13 22:39<span> hooks
</span>-rw-rw-r -- 1 git git 23 Aug 13 22:39<span> HEAD
</span>-rw-rw-r -- 1 git git 73 Aug 13 22:39<span> description
</span>-rw-rw-r -- 1 git git 92 Aug 13 22:39<span> config
drwxrwxr</span>-x 2 git git 4096 Aug 13 22:39<span> branches
drwxrwxr</span>-x 36 git git 4096 Aug 13 22:39 ..<span>
drwxrwxr</span>-x 7 git git 4096 Aug 13 22:39 .
 
4<span>、向工程添加和提交文件
这些动作和CVS、SVN等操作类似
 
$ git add </span>*.java *.<span>c
$ git commit </span>-<span>m &lsquo;Initial upload of the project&rsquo;
create mode </span>100755 Orangebugs.<span>java
create mode </span>100755 pwm/ui/DataManager.<span>java
create mode </span>100755 pwm/ui/PasswordFrame.<span>java
create mode </span>100755 pwm/tools/StrongEncryption.<span>java
create mode </span>100755 pwm/tools/PasswordStrength.<span>java
</span>..<span>
 
注意如果之前没有使用 git config 指定用户名和电子邮件地址,这里会报错
$ git commit </span>-m &lsquo;Initial upload of the project'<span>
 
*** Please tell me who you are.
  www.2cto.com  
Run
 
git config  --global user.email &ldquo;you@example.com&rdquo;
git config  --global user.name &ldquo;Your Name&rdquo;
 
to set your account&rsquo;s default identity.
Omit  --global to set the identity only in this repository.
 
fatal: empty ident not allowed
 
5、更改文件和提交改动
编辑文件、添加或者删除了一些字段
$ vi Orangebugs.java
 
查看和GIT仓库中的文件相比有了那些改动
 
$ git diff
diff  --git a/Orangebugs.java b/Orangebugs.java
index 6166ed1..fd82d32 100644
&mdash; a/Orangebugs.java
+++ b/Orangebugs.java
@@ -2,7 +2,7 @@
- public counter=10
+ public counter=55
 
如果要提交,需要先确保将文件添加到了临时区域(staging area)然后才能提交,提交时会自动打开系统的默认编辑器,用户添加一些注释后保存并退出编辑器的时候,这些注释就同时提交到仓库中去了
  www.2cto.com  
$ git add Orangebugs.java
$ git commit
[master 80f10a9] Added password strength meter functionality
1 files changed, 56 insertions(+), 7 deletions(-)
或者,简单一点的方法是使用 git commit -a 把上面两个命令合二为一。
6、查看状态和查看注释
如果本地的文件和远端GIT仓库上的文件相比没有任何改动,则
 
$ git status
# On branch master
nothing to commit (working directory clean)
 
如果本地做了改动但是没有提交,则
 
$ git status
# On branch master
# Changes not staged for commit:
# (use &ldquo;git add &hellip;&rdquo; to update what will be committed)
# (use &ldquo;git checkout &mdash; &hellip;&rdquo; to discard changes in working directory)
#
# modified: Orangebugs.java
#
no changes added to commit (use "git add" and/or "git commit -a")
 
另外,可以用下面的命令查看文件历史和以往的注释
 
$ git log Orangebugs.java
commit c919ced7f42f4bc06d563c1a1eaa107f2b2420d5
Author: GIT Admin  www.2cto.com  
Date: Sat Aug 13 22:54:57 2011 -0700
 
Added password strength meter functionality
 
commit c141b7bdbff429de35e36bafb2e43edc655e9957
Author: GIT Admin
Date: Sat Aug 13 20:08:02 2011 -0700
 
Initial upload of the project</span>

linux下版本管理git的安装方法,安装包,以及详细的使用介绍,高分重谢

Google一下到处都是
如果你用Ubuntu的话在终端打sudo apt-get install git就装好了
用arch的话打sudo pacman -S git
各种包管理应该都可以 看你用哪种了
自己下代码编译也成
使用的话一两句话说不清 自己去Google教程吧
 

linux ,ubuntu使用git问题怎让git记录我的版本?

用分支或者标签实现,不过看上去标签应该更加合适
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/847128.htmlTechArticleGIT在Linux上的安装和使用简介,gitlinux安装简介 GIT在Linux上的安装和使用简介解压后切换到其目录$ tar xvfj git -1.7.6.tar. bz2$ cd git -1.7.6 使用默...
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
PHP和Python:解釋了不同的範例PHP和Python:解釋了不同的範例Apr 18, 2025 am 12:26 AM

PHP主要是過程式編程,但也支持面向對象編程(OOP);Python支持多種範式,包括OOP、函數式和過程式編程。 PHP適合web開發,Python適用於多種應用,如數據分析和機器學習。

PHP和Python:深入了解他們的歷史PHP和Python:深入了解他們的歷史Apr 18, 2025 am 12:25 AM

PHP起源於1994年,由RasmusLerdorf開發,最初用於跟踪網站訪問者,逐漸演變為服務器端腳本語言,廣泛應用於網頁開發。 Python由GuidovanRossum於1980年代末開發,1991年首次發布,強調代碼可讀性和簡潔性,適用於科學計算、數據分析等領域。

在PHP和Python之間進行選擇:指南在PHP和Python之間進行選擇:指南Apr 18, 2025 am 12:24 AM

PHP適合網頁開發和快速原型開發,Python適用於數據科學和機器學習。 1.PHP用於動態網頁開發,語法簡單,適合快速開發。 2.Python語法簡潔,適用於多領域,庫生態系統強大。

PHP和框架:現代化語言PHP和框架:現代化語言Apr 18, 2025 am 12:14 AM

PHP在現代化進程中仍然重要,因為它支持大量網站和應用,並通過框架適應開發需求。 1.PHP7提升了性能並引入了新功能。 2.現代框架如Laravel、Symfony和CodeIgniter簡化開發,提高代碼質量。 3.性能優化和最佳實踐進一步提升應用效率。

PHP的影響:網絡開發及以後PHP的影響:網絡開發及以後Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP類型提示如何起作用,包括標量類型,返回類型,聯合類型和無效類型?PHP類型提示如何起作用,包括標量類型,返回類型,聯合類型和無效類型?Apr 17, 2025 am 12:25 AM

PHP類型提示提升代碼質量和可讀性。 1)標量類型提示:自PHP7.0起,允許在函數參數中指定基本數據類型,如int、float等。 2)返回類型提示:確保函數返回值類型的一致性。 3)聯合類型提示:自PHP8.0起,允許在函數參數或返回值中指定多個類型。 4)可空類型提示:允許包含null值,處理可能返回空值的函數。

PHP如何處理對象克隆(克隆關鍵字)和__clone魔法方法?PHP如何處理對象克隆(克隆關鍵字)和__clone魔法方法?Apr 17, 2025 am 12:24 AM

PHP中使用clone關鍵字創建對象副本,並通過\_\_clone魔法方法定制克隆行為。 1.使用clone關鍵字進行淺拷貝,克隆對象的屬性但不克隆對象屬性內的對象。 2.通過\_\_clone方法可以深拷貝嵌套對象,避免淺拷貝問題。 3.注意避免克隆中的循環引用和性能問題,優化克隆操作以提高效率。

PHP與Python:用例和應用程序PHP與Python:用例和應用程序Apr 17, 2025 am 12:23 AM

PHP適用於Web開發和內容管理系統,Python適合數據科學、機器學習和自動化腳本。 1.PHP在構建快速、可擴展的網站和應用程序方面表現出色,常用於WordPress等CMS。 2.Python在數據科學和機器學習領域表現卓越,擁有豐富的庫如NumPy和TensorFlow。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 個月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
1 個月前By尊渡假赌尊渡假赌尊渡假赌
威爾R.E.P.O.有交叉遊戲嗎?
1 個月前By尊渡假赌尊渡假赌尊渡假赌

熱工具

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版