Git分布式版本控制教程,git教程

來源:互聯網
上載者:User

Git分布式版本控制教程,git教程

Git分布式版本控制

Git 安裝配置

Linux&Unix平台

Debian/Ubuntu$ apt-get install gitFedora$ yum install git (up to Fedora 21)$ dnf install git (Fedora 22 and later)Gentoo$ emerge --ask --verbose dev-vcs/gitArch Linux$ pacman -S gitopenSUSE$ zypper install gitFreeBSD$ cd /usr/ports/devel/git$ make installSolaris 11 Express$ pkg install developer/versioning/gitOpenBSD$ pkg_add git

 



Windows
官網:https://git-scm.com/download/win

MAC
:https://sourceforge.net/projects/git-osx-installer/

Git 配置
設定使用者名稱稱和電子郵件

git config --global user.name "lingdong"git config --global user.email "lingdong@wld5.com"


查看配置資訊

git config --list


使用Git分布式版本控制系統工作流程

複製資料到本地機器工作目錄
在本地建立的分支,修改代碼
在自己建立的分支上進行提交代碼
修改完畢後把分支與主分支進行合并
推送本地代碼到遠程伺服器
版本倉庫管理員進行審核,使用允許推送


三大開來源站點點

SourceForge
codeplex
Github

Git常用命令

初始化&&複製
git init git clone


建立項目

add (將檔案添加到緩衝區)& commit

git add *git add README

將緩衝區內容添加到倉庫中,-m 在命令列中提供提交注釋

git commit -a -m "init project version"

git push命令 將本地分支,推送到遠程主機

git push origin master

如果出現以下錯誤:

To https://git...git
![rejected] master -> master (fetch first)error: failed to push some refs to https://git...githint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changes

使用命令進行解決

git push -f


status檢查檔案狀態

git status


Ignore file 忽略指定檔案
cat .gitignore 忽略檔案
vim .gitignore 添加忽略的檔案

diff
git diff
git diff --staged
git diff --cached 查看已緩衝的改動


git reset HEAD  用於取消已緩衝的內容
git reset HEAD -- hello.jsp

git rm  將檔案從緩衝區和你的硬碟中(工作目錄)刪除
git rm hello.jsp


git mv  重新命名磁碟上的檔案 與 git rm --cached 命令的操作一樣的效果

git fetch是從遠程擷取最新版本到本地

git fetch origin mastergit log -p master origin/mastergit merge origin/master


git pull 從遠程擷取最新版本並merge到本地

git pull origin master

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.