歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> Ubuntu14.04下Git安裝和使用快速入門

Ubuntu14.04下Git安裝和使用快速入門

日期:2017/3/3 12:19:51   编辑:Linux技術
Git是目前世界上最先進的分布式版本控制系統,GitHub是一個使用Git來托管代碼的網站。
(關鍵詞:repository:版本庫又名倉庫)
Git的安裝:
方法一:下載Git源碼編譯安裝
https://github.com/git/git 下載源代碼
可選方法:git clonehttps://github.com/git/git
1.檢查出歷史所有的版本(默認檢出的是最新版本):git tag
2.選擇檢出(checkout)的版本:git checkout v1.7.8.2(example)
sudo apt-get install openssl
sudo apt-get install libssl-dev build-essential zlibc zlib-bin libidn11-dev libidn11
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libexpat1-dev
make prefix=/usr/local all
sudo make prefix=/usr/local install
方法二:從源中安裝
sudo apt-get update 獲得最近的軟件包的列表;
sudo apt-get install git
測試是否安裝成功:git --version
Git的基本配置
git config --global user.name "Your Name Here"
git config --global user.email [email protected]
查看已有的配置信息:git config --list
Git的使用
(1)初始化:新建一個文件夾(git_project),cd 進去,建立代碼倉庫
git init
進入該文件夾,將文件顯示隱藏可見(ls -a),裡面會生成.git文件
將需要被管理的項目(LiteNES)放到文件夾git_project下
git status
git add LiteNES
git commit -m "init the project"
(2)修改文件並恢復:
打開文件LiteNES/src/main.c 編輯修改
cd LiteNES
git add ./src/main.c
git commit -m "add code comment"
git log
git show dcf7c11e403f7e4ff129aab01e6b6962e1120a77
git revert dcf7c11e403f7e4ff129aab01e6b6962e1120a77
(vim) wq!保存退出 即恢復成了修改前的狀態。
參考文獻:[1][原創]Ubuntu 12.04 下 GitHub安裝和使用快速入門(更新中):https://git-scm.com/book/zh/v1
[2]Git中文文檔:https://git-scm.com/book/zh/v1/%E8%B5%B7%E6%AD%A5
[3]使用Git管理本地項目:http://www.linuxidc.com/Linux/2014-03/98367.htm
Copyright © Linux教程網 All Rights Reserved