Git distributed version control tutorial, git tutorial

Source: Internet
Author: User
Tags version control system git commands

Git distributed version control tutorial, git tutorial

Git distributed version control

Git installation Configuration

Linux and Unix platforms

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
Official Website: https://git-scm.com/download/win

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

Git Configuration
Set User name and email

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


View configuration information

git config --list


Git distributed version control system Workflow

Clone data to the local machine working directory
Modify the code of a local branch
Submit code on your own branch
Merge the branches with the main branches after modification.
Push local code to remote server
Version repository Administrator review and use push allowed


Three open source sites

SourceForge
Codeplex
Github

Common Git commands

Initialization & Cloning
git init git clone


Create a project

Add (add a file to the cache) & commit

git add *git add README

Add the content in the cache area to the repository.-m provides comments for submission in the command line.

git commit -a -m "init project version"

Git push command to push local branch to remote host

git push origin master

If the following error occurs:

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

Use commands to solve the problem

git push -f


Status check file status

git status


Ignore file ignores the specified file
Cat. gitignore ignores files
Vim. gitignore: Add ignored files

Diff
Git diff
Git diff -- staged
Git diff -- cached view cached changes


Git reset HEAD is used to cancel cached content
Git reset HEAD -- hello. jsp

Git rm deletes files from the cache and your hard disk (working directory)
Git rm hello. jsp


Renaming files on a disk using git mv is the same as running the git rm -- cached command.

Git fetch is used to remotely obtain the latest version to the local device.

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


Git pull gets the latest version from a remote device and merge to the local device.

git pull origin master

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.