Full git operation on a project

Source: Internet
Author: User

Download the project on Git to a local

1. Download the project to a local

git Clone (git project address)

2. Go to the project folder (CD folder) switch to the branch you want to use

git checkout Develop

3. Crawl Remote repository Develop branch update and merge to local

Git pull origin Develop

Develop iterative phases to develop on develop as an example

After modifying the file, use git status (to see which files have been modified)

Git Add File path (Select this commit file, the file path can be multiple file paths separated by a space)

Git commit (this will go into vim mode and record the commit description of this commit)

Git push origin develop

Git pull origin Develop

Late development, release stable version develop development new features, project change bug to merge to two branches

Background: Currently we develop the project "cloud form", to use two branches, develop, Release,develop is used to develop new features, release is a relatively stable version, test release version, test pass will be pushed directly to the Maven warehouse, 1 is for other project calls, 2 pushed to the line, if there is a bug in this process how to solve? Our solution is to submit the bug to the release branch, of course, to submit to the develop branch, my development manager strongly recommended to cut a local branch to modify the bug, (can be arbitrarily changed, will not affect others o_o haha) following to create a new branch 0730bug_ Release for example

1. Cut a local branch on the release branch and switch to the new branch

Git checkout-b 0730bug_release (name yourself, I'm used to start with the current date, and on which branch to pull out the new branch is the end)

"This command is equivalent to":

Git branch 0730bug_release (create new branch)

git checkout 0730bug_release (switch branch)

2, in the new cut branch 0730bug_release Modify the bug

After modifying the file, use git status (to see which files have been modified)

Git Add File path (Select this commit file, the file path can be multiple file paths separated by a space)

Git commit (this will go into vim mode and record the commit description of this commit)

This process can be repeated multiple times

3, assume that after multiple commits, to merge to the use of the two branches

First: Git status to see if the local file has been modified, but does not want to commit the

If so, git stash (save the changed files)

"Merge to release": Because this branch is cut out on the branch of release, the process is relatively simple

git checkout Release

Git pull Origin Release

git merge 0730bug_release

If this command executes or causes a conflict, resolve the conflict and resolve the conflict

Git push origin release

"Merge to develop": 0730bug_release is not taken from develop, so it will be different.

git log (Find a commitid in the current branch 0730bug_release, this commitid is the previous commitid of the first commit of the current merge)

git checkout Develop

Git pull origin Develop

git checkout 0730bug_release

git rebase--onto=develop Commitid

git checkout Develop

To see if there is a conflict resolution conflict

Git push origin develop

"Merge once to which branch is the same, take merge to develop for example"

Git log (on the current branch 0730bug_release, find the Commitid to merge)

git checkout Develop

Git pull origin Develop

Git Cherry-pick commitid

To see if there is a conflict resolution conflict

Git push origin develop

Other common commands

Git branch (see all local branches)

Git branch-d 0730bug_release (forcibly delete 0730bug_release branch)

git reset--hard commitid (rollback to a commitid state)

Full git operation on a project

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.