git command Add modify delete conflict resolution

Source: Internet
Author: User

If you are unfamiliar with the git command line, use the Git graphical interface tool, which is more appropriate. It is recommended that you use a tool such as Tortoisegit, which has a high cost of time from learning to flexible mastery.

1, add

# git clone git@192.168.10.202:develop/test.git

# CD Test

# Touch Test.txt//test files

# git add test.txt//git adding files

# git commit-m ' Test '//Add to local version library

# git push//push to remote

If push complains, perhaps you should specify a branch such as ' master '

Solution:

# Git push Origin master//As long as this is done, you can use Git push later

adding files and adding directories is the same operation.

2, modify the file

Method One

# echo "11111111111" > Test.txt

# git add test.txt && git commit-m ' test2 '

# git push

Method Two

# echo "abc" > Test.txt

# git Commit-am "test3"/all modifications will be submitted

# git push

What if you have multiple files and you want to submit only one or more of them?

# git commit-a//This command appears with the following contents

# Please enter the ' commit ' for your changes. Lines starting

# with ' # ' would be ignored, and a emptyempty message aborts the commit.

# on Branch Master

# Changes to be committed:

# (use ' git reset head ... ' to unstage)

#

# Modified:ab

# Modified:test.txt//If only want to submit the test.txt, just put the line before the # Remove, save the exit on the line

# git push//exit after executing push

3, delete

# git RM ab//If delete directory, plus-R

# git commit-am "del"

# git push

4, conflict resolution

# git push//push don't go up

Address 192.168.10.202 maps to unassigned.psychz.net, but this does not map back to the address-possible break-in attemp T!

To Git@192.168.10.202:develop/test.git

! [Rejected] Master-> Master (Non-fast-forward)

Error:failed to push some refs to ' 192.168.10.202:develop/test.git '

To prevent losing history, Non-fast-forward updates were rejected

Merge the remote changes before pushing again. The ' note about

Fast-forwards ' section of ' git push--help ' for details.

# git pull//update code, hint conflict

Address 192.168.10.202 maps to unassigned.psychz.net, but this does not map back to the address-possible break-in attemp T!

Remote:counting Objects:5, done.

Remote:compressing objects:100% (2/2), done.

Remote:total 3 (Delta 0), reused 0 (Delta 0)

Unpacking objects:100% (3/3), done.

From 192.168.10.202:develop/test

367dad3.. 5e5640b Master-> Origin/master

Auto-merging Test.txt

CONFLICT (content): Merge CONFLICT in Test.txt

Automatic merge failed; Fix conflicts and then commit the result.

# VIM Test.txt//modify conflict file, and save

# git Commit-am "remove conflict"//resubmit to local version library

# git push//sync to remote

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.