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

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

1、下载和安装GIT

#下载
wget http://kernel.org/pub/software/scm/git/git-1.7.6.tar.bz2
#解压
tar xvfj git-1.7.6.tar.bz2
#编译安装
cd git-1.7.6
./configure
make
make install

2、初始化配置

#验证是否安装好
whereis git
git: /usr/local/bin/git
git  --version
git version 1.7.6
git  --help
#指定用户名和电子邮件
git config  --global user.name “GIT Admin”
git config  --global user.emal obugs.net@gmail.com
#验证配置信息
git config  --list
user.name=GIT Admin
user.email=obugs.net@gmail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
#查看配置文件
cat ~/.gitconfig

[user]
name = GIT Admin
email = obugs.net@gmail.com

3、建立工程

#定义git工程
cd /home/obugs/projects/orangebugs
git init
Initialized empty Git repository in /home/obugs/projects/orangebugs/.git/
#授权
ls -altr .git
total 40
drwxrwxr-x 4 git git 4096 Aug 13 22:39 refs
drwxrwxr-x 4 git git 4096 Aug 13 22:39 objects
drwxrwxr-x 2 git git 4096 Aug 13 22:39 info
drwxrwxr-x 2 git git 4096 Aug 13 22:39 hooks
-rw-rw-r -- 1 git git 23 Aug 13 22:39 HEAD
-rw-rw-r -- 1 git git 73 Aug 13 22:39 description
-rw-rw-r -- 1 git git 92 Aug 13 22:39 config
drwxrwxr-x 2 git git 4096 Aug 13 22:39 branches
drwxrwxr-x 36 git git 4096 Aug 13 22:39 ..
drwxrwxr-x 7 git git 4096 Aug 13 22:39 .

4、向工程添加和提交文件

#添加文件
git add *.java *.c
git commit -m ‘Initial upload of the project’
create mode 100755 Orangebugs.java
create mode 100755 pwm/ui/DataManager.java
create mode 100755 pwm/ui/PasswordFrame.java
create mode 100755 pwm/tools/StrongEncryption.java
create mode 100755 pwm/tools/PasswordStrength.java
#注意如果之前没有使用 git config 指定用户名和电子邮件地址,这里会报错
git commit -m ‘Initial upload of the project'

*** Please tell me who you are.  
Run
git config  --global user.email “you@example.com”
git config  --global user.name “Your Name”
to set your account’s default identity.
Omit  --global to set the identity only in this repository.
fatal: empty ident not allowed

5、更改文件和提交改动

#更改文件
vi Orangebugs.java
#比较差异
git diff
diff  --git a/Orangebugs.java b/Orangebugs.java
index 6166ed1
..fd82d32 100644 — a/Orangebugs.java +++ b/Orangebugs.java @@ -2,7 +2,7 @@ - public counter=10 + public counter=55 #提交文件 git add Orangebugs.java git commit
[master 80f10a9] Added password strength meter functionality
1 files changed, 56 insertions(+), 7 deletions(-)

6、查看状态和查看注释

#查看状态(无改动)
git status

# On branch master
nothing to commit (working directory clean)
#查看状态(有改动但未提交)
git status
# On branch master # Changes not staged for commit: # (use “git add …” to update what will be committed) # (use “git checkout — …” 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

 

转载于:https://www.cnblogs.com/boystar/p/4741414.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/109353.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 在docker 上安装lnmp 环境

    在docker 上安装lnmp 环境

    2022年2月19日
    39
  • python3实现网络字节序和ipv4、ipv6互转[通俗易懂]

    文章目录1.前言2.什么是是网络字节序3.ipv4和ipv6简介4.转换5.参考文献1.前言2.什么是是网络字节序3.ipv4和ipv6简介4.转换5.参考文献[1][2]

    2022年4月11日
    326
  • pycharm2019.3.3激活教程_pycharm2020.2激活码

    pycharm2019.3.3激活教程_pycharm2020.2激活码下载官网下载2019.03最新版http://www.jetbrains.com/pycharm/download/download-thanks.html?platform=windows安装一路点击下一步,安装目录建议放在非C盘位置激活方式1:激活码第一次打开时,激活方式选择激活码。复制粘贴下面一整行,点击激活即可。有效期是2019年11月份,到时候会更新新的激活码。这种方式…

    2022年8月25日
    6
  • Java Integer最大值最小值输出

    Java Integer最大值最小值输出System.out.println(Integer.MAX_VALUE);System.out.println(Integer.MAX_VALUE+1);System.out.println(Integer.MIN_VALUE);System.out.println(Integer.MIN_VALUE-1);输出结果如下:2147483647-214748364

    2025年10月7日
    2
  • Windows小工具 tcping

    Windows小工具 tcpingWindows小工具tcping一、ping和tcping的区别1指代不同1、ping:是Windows、Unix和Linux系统下的一个命令。ping也属于一个通信协议,是TCP/IP协议的一部分。通过ICMP协议发送报文到对方主机上任意一个60000以上的端口,然后获取对方主机的回复2、tcping:是一种面向连百接的、可靠的、基于字节流的传输层通信协议。使用tcp协议尝试与某一个端口建立连接,然后获取与对方主机建立一次连接的回复2功能不同1、ping:利用“ping”命令可以检查网

    2022年6月23日
    42
  • k8s–证书签发

    k8s–证书签发1.准备签发证书环境运维主机hdss-1-200.host.com上:2.安装CFSSL证书签发工具CFSSL:R1.2cfssl下载地址https://pkg.cfssl.org/R1.2/cfssl_linux-amd64cfssl-json下载地址https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64cfssl-certinfo下载地址https://pkg.cfssl.org/R1.2/cfssl-certinfo_li…

    2022年5月9日
    94

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号