search
HomeBackend DevelopmentPHP TutorialIntroduction to the installation and use of GIT on Linux, introduction to gitlinux installation_PHP tutorial

Introduction to the installation and use of GIT on Linux, introduction to gitlinux installation

<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>

Installation method of git version management under Linux, installation Package, and detailed usage introduction, high marks and thanks

Google it everywhere
If you use Ubuntu, run sudo apt-get install git in the terminal and it will be installed
If you use arch, run sudo pacman -S git
All kinds of package management should be available It depends on which one you use
You can also compile the code yourself
If you can’t explain it in a sentence or two, go to Google for tutorials

Linux, how can I make git record my version when using git on ubuntu?

Use branches or tags to implement, but it seems that tags should be more suitable

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/847128.htmlTechArticleIntroduction to the installation and use of GIT on Linux, introduction to gitlinux installation Introduction to the installation and use of GIT on Linux After decompression Change to its directory $ tar xvfj git -1.7.6.tar. bz2$ cd git -1.7.6 Use default...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What data can be stored in a PHP session?What data can be stored in a PHP session?May 02, 2025 am 12:17 AM

PHPsessionscanstorestrings,numbers,arrays,andobjects.1.Strings:textdatalikeusernames.2.Numbers:integersorfloatsforcounters.3.Arrays:listslikeshoppingcarts.4.Objects:complexstructuresthatareserialized.

How do you start a PHP session?How do you start a PHP session?May 02, 2025 am 12:16 AM

TostartaPHPsession,usesession_start()atthescript'sbeginning.1)Placeitbeforeanyoutputtosetthesessioncookie.2)Usesessionsforuserdatalikeloginstatusorshoppingcarts.3)RegeneratesessionIDstopreventfixationattacks.4)Considerusingadatabaseforsessionstoragei

What is session regeneration, and how does it improve security?What is session regeneration, and how does it improve security?May 02, 2025 am 12:15 AM

Session regeneration refers to generating a new session ID and invalidating the old ID when the user performs sensitive operations in case of session fixed attacks. The implementation steps include: 1. Detect sensitive operations, 2. Generate new session ID, 3. Destroy old session ID, 4. Update user-side session information.

What are some performance considerations when using PHP sessions?What are some performance considerations when using PHP sessions?May 02, 2025 am 12:11 AM

PHP sessions have a significant impact on application performance. Optimization methods include: 1. Use a database to store session data to improve response speed; 2. Reduce the use of session data and only store necessary information; 3. Use a non-blocking session processor to improve concurrency capabilities; 4. Adjust the session expiration time to balance user experience and server burden; 5. Use persistent sessions to reduce the number of data read and write times.

How do PHP sessions differ from cookies?How do PHP sessions differ from cookies?May 02, 2025 am 12:03 AM

PHPsessionsareserver-side,whilecookiesareclient-side.1)Sessionsstoredataontheserver,aremoresecure,andhandlelargerdata.2)Cookiesstoredataontheclient,arelesssecure,andlimitedinsize.Usesessionsforsensitivedataandcookiesfornon-sensitive,client-sidedata.

How does PHP identify a user's session?How does PHP identify a user's session?May 01, 2025 am 12:23 AM

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

What are some best practices for securing PHP sessions?What are some best practices for securing PHP sessions?May 01, 2025 am 12:22 AM

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

Where are PHP session files stored by default?Where are PHP session files stored by default?May 01, 2025 am 12:15 AM

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use