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)
上一篇 2021年9月8日 下午5:00
下一篇 2021年9月8日 下午5:00


相关推荐

  • 全球首次:消息称国星宇航基于OpenClaw完成太空算力“养虾”试验

    全球首次:消息称国星宇航基于OpenClaw完成太空算力“养虾”试验

    2026年3月16日
    1
  • linux挂载U盘的方法

    linux挂载U盘的方法现在的 usb 设备很多 如 mp3 u 盘 读卡器等 但在 linux 上不一定被认出来 比如说我的读卡器 1gmmc 卡通过 mount 命令能够被 redhatlinux 挂载 但我的 mp3 和清华紫光的 u 盘确不能够被识别 在网上搜索了很多的方法 但都不成功 现把自己总结的经验分享出来 插入 U 盘之后 按照下面的步骤 1 fdisk l dev sd nbsp nbsp nbsp fdisk l 列出指定设备的分区表信息

    2026年3月17日
    2
  • android错误之android.os.NetworkOnMainThreadException

    在做一个天气预报的widget的时候,参考了一个源代码,但是一直报错,就从里面抠出来获取天气的代码试试看,结果总是报错 就是这个异常,android.os.NetworkOnMainThreadException代码是这样的:MainActivity:public class MainActivity extends Activity { MyWeather myWe

    2022年3月10日
    40
  • Hibernate入门第一讲——Hibernate框架的快速入门

    Hibernate入门第一讲——Hibernate框架的快速入门Hibernate 框架介绍什么是 Hibernate 我们可以从度娘上摘抄这样有关 Hibernate 的介绍 Hibernate 是一个开放源代码的对象关系映射框架 它对 JDBC 进行了非常轻量级的对象封装 它将 POJO 与数据库表建立映射关系 是一个全自动的 orm 框架 hibernate 可以自动生成 SQL 语句 自动执行 使得 Java 程序员可以随心所欲的使用对象编程思维来操纵数据库 Hibernate 可以

    2026年3月19日
    2
  • 三步解决error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“

    三步解决error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“根据报错 是系统中缺少编译 C 的功能 我用以下方法解决 1 下载 VisualStudio 下载时会有添加到 PATH 的选项 默认是选上的 一定不要取消 2 在 VisualStudio 中安装 C 插件

    2026年3月19日
    2
  • ARM 软中断指令SWI

    ARM 软中断指令SWI前面我们学习 ARM 工作模式中 处理器模式切换可以通过软件控制进行切换 即修改 CPSR 模式位 但这是在特权模式下 当我们处于用户模式下 是没有权限实现模式转换的 若想实现模式切换 只能由另一种方法来实现 即通过外部中断或是异常处理过程进行切换 于是 ARM 指令集中提供了两条产生异常的指令 通过这两条指令可以用软件的方法实现异常 其中一个就是中断指令 SWI nbsp nbsp 一 软件中断 nbsp nbsp nbsp nbsp nbsp nbsp nbsp 软中

    2026年3月18日
    2

发表回复

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

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