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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • BLSP接口_jcom接口

    BLSP接口_jcom接口http://huaqianlee.github.io/2016/04/27/Uav/Qualcomm-uav-blsp-port/概述BLSP是高通对于低速接口的一种管理方式,8074平台含有两个BLSP(BAMLow-SpeedPeripheral)块,对应于12个BLSP端口。每一个BLSP块含有最多六个QualcommUniversalPe

    2022年10月19日
    0
  • qq刷屏代码如何停止(微信刷屏代码vbs)

    最近有些人向小编反应QQ刷屏代码没办法关,小编认为有必要发布一下关程序的代码,专门针对上次的QQ刷屏代码:sety=getobject(“winmgmts:\\.\root\cimv2”)setx=y.execquery(“select*fromwin32_processwherename=’wscript.exe'”)foreachiinxi.terminat…

    2022年4月17日
    110
  • VS2013注册码_vs激活码怎么用

    VS2013注册码_vs激活码怎么用vs2012注册码YKCW6-BPFPF-BT8C9-7DCTH-QXGWCRBCXF-CVBGR-382MK-DFHJ4-C69G8MMVJ9-FKY74-W449Y-RB79G-8GJGJ4D974-9QX42-9Y43G-YJ7JG-JDYBPYCFHQ-9DWCY-DKV88-T2TMH-G7BHP亲测有效!

    2022年8月31日
    3
  • tensorflow(gpu) win10安装 1060显卡驱动[通俗易懂]

    tensorflow(gpu) win10安装 1060显卡驱动[通俗易懂]CUDA9.0+cuDNNv7+WIN10+1060显卡一.驱动文件下载1.上tensorflow官网。查看本机硬件和系统支持的tensorflow版本,以及对应的cuda和cuddnn版本。https://www.tensorflow.org/install/install_windows?hl=zh-cn2.百度进CUDA网站。查找相应的CUDA驱动。打开默认下载是9.2版本,如下…

    2022年5月9日
    209
  • vue 创建新项目

    vue 创建新项目1 vue 依赖于 npm 和 node 有因为 npm 依赖于 node 所以在新建项目前先安装好 node 也可以安装 nvm 后续方便切换 node 版本 打开 cmd 窗口 输出 node v 看看有无安装成功 有显示指定版本说明 node 安装成功 2 安装脚手架 vue cli 输入命令 npminstall g vue cli 接着用命令 vueversion 查看是否安装成功 3 新建项目 命令 vuecreate 项目名 4 创建成功 按照提示进入 vscode 切换到指定文件夹 执行 npmruns

    2025年7月3日
    2
  • python中list与string的转换「建议收藏」

    python中list与string的转换「建议收藏」1.list转string命令:”.join(list)其中,引号中是字符之间的分割符,如“,”,“;”,“\t”等等如:list=[1,2,3,4,5]”.join(list)结果即为:12345′,’.join(list)结果即为:1,2,3,4,5str=[]#有的题目要输出字符串,但是有时候list更好操作,于是可以最后list转st…

    2022年6月13日
    356

发表回复

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

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