Use Git version control tools in project development to improve efficiency

Source: Internet
Author: User

Use Git version control tools in project development to improve efficiency

Install Git (Linux CentOS platform)
 
Source code Installation
 
1. Install dependency
 
$ Yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
 
2. Compile and install the source code
 
Address: http://git-scm.com/download
 
Compile and install:
 
$ Tar-zxf git-1.7.2.2.tar.gz
$ Git-1.7.2.2 cd
$ Make
$ Sudo make install
 


Binary Package Installation
 
$ Yum install git-core

 

Use Git
 
# Create your own working directory
Sudo mkdir/var/www/site/mycitsm_zyz
Cd/var/www/site/mycitsm_zyz
 
# Clone code from the code repository
Sudo Gitclone ssh: // username @ ip: port/path/to/example. git/path/to/workdir
 
# Clone the code to your working directory and set the information to help identify the update source.
$ Git config user. name "username"
$ Git config user. email username@example.com
 

# Ignore certain files
Create and edit the. gitignore file in the working directory, and write the content you want to ignore.
Example:
$ Cat. gitignore
*. Pyc
*. Pyo
Test _*
*. Bak
 

 


Then you can edit and submit the code in your working directory.
 
General Workflow
# Update code
$ Vim/path/to/file
 
# Viewing File status
$ Git status
 
# Temporary update
$ Git add/path/to/file
 
# Submit updates locally
$ Git commit-m "Description"
Or pass
$ Git commit-v: write more detailed submission instructions and record specific updates.
 
# Push local updates to a remote Repository
$ Git push origin master (origin is the assumed remote repository name, master is the default Branch)
 
# Pull new content from remote Repository
$ Git pull origin
 
# Getting help
$ Git help
 

# Create a branch
$ Git branch branchname
 
# Switch Branch
$ Git checkout branchname
 

# The preceding two steps can be merged into one step.
$ Git checkout-B branchname
 
# Merge branches
 
Switch back to master branch $ git checkout master
Merge the branches to the main branch $ git merge branchname
# View branches
$ Git branch
 
# View only unmerged branches
$ Git branch -- no-merged
 
# View only merged branches
$ Git branch -- merged
 
# Delete a branch (merged)
$ Git branch-d branchname
 
# Delete a branch (whether merged or not)
$ Git branch-D branchname
 

# View the differences between unsaved files and those before modification
 
$ Git diff
 
# View the difference between the saved files and the snapshot that was last submitted
$ Git diff -- cached
 
# Removing files
$ Git rm/path/to/file
 
# Only deleting from the trail list and not from the working directory
$ Git rm -- cached/path/to/file
 
# Moving Files
$ Git mv file_from file_to
 
# View submission history
$ Git log
 
# Last modification submission
$ Git commit -- amend
 
# Cancelling saved files
$ Git reset HEAD/path/to/file
 
# Cancelling modification to a file pair
$ Git checkout --/path/to/file
 
# Rollback
$ Git reset -- mixed HEAD ~ N
$ Git reset -- soft HEAD ~ N
$ Git reset -- hard HEAD ~ N
N indicates the last N commits. Here it can also be the unique identifier of the version returned after a Commit (which can be obtained through $ git log)
-- Mixed retains the changes and rolls back the commit and index
-- Soft retains the changes, rolls back the commit, and does not roll back the index.
-- Hard is completely rolled back to a specific version.
 
# View the current remote database
$ Git remote-v
 
# Pull updates from remote databases
$ Git fetch origin

# Merge pulled update branches to local branches
$ Git merge origin/master
 
The preceding two steps can be merged into one step.
$ Git pull origin

Install GitLab on Ubuntu 12.04

GitLab 5.3 upgrade considerations

Deploy GitLab on CentOS (self-managed Git project repository)

Install GitLab 6.0.2 on RHEL6/CentOS6/ScientificLinux6

CentOS 6.5 GitLab installation tutorial and Related Problems

GitLab details: click here
GitLab: click here

This article permanently updates the link address:

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.