- Workspace: Work Area
- Index/stage: Staging Area
- Repository: Warehouse area (or local warehouse)
- Remote: Repository
Common git commands
# Download a project and its entire code history
$ git clone [url]
# Download a project and specify a branch
$ git clone-b [branch name] [url]
# Show files with changes
$ git status
# Add all files from the current directory to staging area
$ git Add.
# List all local branches
$ git Branch
# List all remote branches
$ git branch-r
# Create a new branch and immediately switch to that branch
$ git checkout-b [branch]
# Submit staging Area to warehouse area
$ git commit-m "message"
# Retrieve remote repository changes, merge with local branch
$ git pull origin [url]
# Upload locally designated branch to remote repository
$ Git push origin [url]
# shows the version history of the current branch
$ git log
# Show staging area and workspace differences
$ git diff
The development process on the Gitlab
One, the development
1, create branch A on Gitlab
2, create a static resource port for branch A in the Automation update platform, tell the PHP port number
3, after branch A has been developed to commit to remote branch A, update the branch a static resource port on the automation platform
Second, the test
1, Bug modification on branch a
Third, on-line to pre-production backbone
1, initiate request merge branch A to branch on Gitlab develop
2, when the merge is complete, update to the pre on the Automation update platform
Four, on-line
1, in the Automation Update platform Point project on-Line (branch develop merged to branch release)
2, send online mail
3. Merge branch release to master on Gitlab after online completion
When merged to master, and assigned to the project owner (or review)
1. After submitting the Merge Request, the assigned person may @someone invite one or more additional Reviewer (they will receive an email notification)
2. Invited Reviewer after reading the code, can reply :thumbsup: or +1 Express through, and vice versa to give suggestions for modification.
# git development on-line operation process
The way git checks out addresses into HTTP and SSH.
Using SSH after configuring the Ssh-key (configuration method reference website description document) can be done without entering a user name and password.
# # command-line Operations
Global configuration:
The log in the commit code will show the submitter's information
git config--global user.name [username]
git config--global user.email [email]
Note: This is usually the first time you use Git to set up or want to modify the configuration information.
If it is based on the original business development, create a new directory directly to do the operation.
# # 1. Create a branch and check out a branch
git clone project address (SSH)
Git clone-b Develop project address (drop-down develop)
git checkout feature-xxx (branch name)
# # 2. Pull up the latest code
In the current branch directory
Git pull
Pull to make a branch
Git pull Origin feature-xxx (branch name)
# # 3. Modify the Commit code
After checking out the code and making the changes:
Git status (view current modified state)
-Submit modifications to the local repository
git Add. ("." Commits all changes in the current directory)
git add xxx (submit specified directory)
Git add-a (commit all modifications)
git commit-m "modified comment information" (must be detailed)
# # 4. Push to remote branch
Git push Origin feature-xxx
# # 5. Code merging (taking feature-xxx to develop as an example)
1) Git pull Origin feature-xxx (update before merging to avoid new changes)
2) git checkout Develop
3) Git pull Develop
4) git merge feature-xxx
If there is a conflict after the merge, the console will give the conflicting file, resolve the conflict, and then commit the push.
# # 6. Ways to resolve conflicts
When Git pull/git push/git maerge, if two branches have modified the code
There will be conflicts in the circumstances. The console will output the corresponding conflicting files, find the corresponding files to modify, and then go to add, commit, push.
# # 7. Code rollback
Git log (can see all the commit history, can take parameters, specific use of the details of their own search)
Rollback operations allow rollback to a prepared commit version:
git reset--hard [version hash version number to roll back]
Company Gitlab Development