Some useful links :

Git Development mode :

Suggest at least one master and develop Branch .master Only do version maintenance ,develop Used to develop . After the development is completed and the test is passed, merge into master.

Common scenarios :

  •   Unsubscribe to Remote Of commit Or local rollback

Compulsory way :

If you push it to remote Of commit Not by anyone else pull too , Then you can use

git reset --hard <commit-hash>
git push -f origin master ( Suppose both local and remote are right master To operate )

To undo a previously submitted commit.

Compatibility mode ( Recommended ):

But if someone else synced your push, Then the use of coercion will bring problems to others .

You can use it locally revert To restore your submitted commit, And then you generate a new one commit And then push it to the far end . As follows :

Suppose the current state is as follows :

State before rollback

We hope that fb43619 Of commit Roll back , You can use :

git revert HEAD~1 (HEAD~1 Express HEAD Former one commit, And so on ) perhaps   git revert fb43619

In this way, we will get no right commit The state of . Then we can continue to edit and submit on this basis , Last push To Remote.

State after local rollback ( not yet push To Remote)

It is worth mentioning that ,6bb916commit The content of will not be rolled back , namely revert The operation will only focus on one commit It works .

If we don't need this rollback , Sure :

git revert HEAD   perhaps  git revert a58f231

The results are as follows :

Roll back push After remote and undo local rollback state ( Undo local rollback has not yet push To Remote)

After rolling back 、 After undo rollback , We go back to the beginning :

Undo state after rollback

however , We can find out log Added two rollback operation records in .

  • Delete Remote Branches that you don't need on

git push origin :<delete branch>

  • Local rollback

The main command :git revert and git reset

git revert Is to generate a new commit to undo a commit , Before this submission commit Will be preserved ,revert The operation itself is also recorded .
git reset It's going back to a submission , Submit and before commit Will be preserved , But later changes will be returned to the staging area ( As the case may be ). The operation itself is not logged .

--soft Only commit Rolled back ,index And the content remains unchanged

--mixed commit and index All are rolled back , The content remains the same

--hard commit and index All are rolled back , Content is reset , The later content can't be retrieved

notes :git reset Can be used to merge multiple commit Record .

Possible problems :

  • git status/add Chinese garbled

scene :

Use git add Add files or use git status When viewing the status , The Chinese file name will be displayed as 274\232\350\256\256\346\200\273\347\273\223.png  The mess of
Solution :
git config --global core.quotepath false

Reference link :

  • Adding a new SSH key to the ssh-agent

Reference link :

Git More related articles on related knowledge

  1. git Related knowledge (github,idea Etc )

    Local git Submit documents to github On : 1. stay github Create project on 2. Use git clone Clone locally 3. Editing project 4.g ...

  2. git Related knowledge : How to avoid unnecessary submission of some documents

    Check all commands git help -a See all the concept explanations git help -g Specific help information for a command git help command How to avoid unnecessary submission of some documents ? Cooperative development of personal agreement not to upload the file ...

  3. SC || Git Related knowledge

    Find the big man's blog : notes : The picture is from my little sister's notes ~ ┉┉┉∞ ∞┉┉┉┉∞ ∞┉┉┉∞ ∞┉┉┉┉┉∞ ∞┉┉┉┉∞ ...

  4. podSpec Document related knowledge arrangement

    In the last article, I used SVN The process of creating a private library , This article will sort out the problems related to podSpec Knowledge of documents . podSpec in spec The full name is “Specification”, The meaning of the manual . seeing the name of a thing one thinks of its function , It's used to describe you ...

  5. 【Python Take your time (5)】 Class inheritance case analysis ,python Related knowledge extension

    Class inheritance case analysis ,python Related knowledge extension author : Bai Ningchao 2016 year 10 month 10 Japan 22:36:57 Abstract : Following < Learn quickly python> After one article , The author will python Study the official documents carefully . Official ...

  6. Move WEB Pixel related knowledge

    Learn about mobile web Pixel knowledge , The main purpose is to have a clear idea when cutting the picture . This paper focuses on one problem : How to get the logical pixels we need according to the screen size and physical pixels provided by the device manufacturer ? Focus on this problem with iphone5 As an example to explain the web Pixel correlation ...

  7. listener About the monitor

    I learned from other people's blogs listener I'd like to share my knowledge with you now 1. Concept : A listener is a common device that implements a specific interface java Program , This program is dedicated to listening to another java Object's method call or property change , When the monitored object happens ...

  8. UIViewController Related knowledge

    title: UIViewController Related knowledge date: 2015-12-13 11:50categories: IOS tags: UIViewController Little program, my blog :h ...

  9. 【 turn 】java NIO Related knowledge

    Original address : Java NIO(New IO) It's from Java 1.4 A new version of IO API, Can replace the standard ...

Random recommendation

  1. CI Framework acquisition post and get Parameters CodeIgniter

    Please refer to :CI The input class section of the document : $this->input->post() $this->input->get() ------------------------------- ...

  2. Data model LP32 ILP32 LP64 LLP64 ILP64

    each C++ The size of the underlying type chosen by the implementation is collectively referred to as " Data model ". There are four widely used data models : 32 Bit system : LP32 or 2/4/4(int by 16-bit,long And the pointer is 32 ...

  3. Service discovery consul cluster Build 【 turn 】

    consul cluster setup Introduction and guide : consul For service discovery . When the underlying services change , Be able to update the correct mysql service IP. And provide business query . But you need to write your own scripts , Monitor database status and shut down ...

  4. On the development of python adopt os Modules store data

    # In fact, I am tired of blogging , But it's better to send it for the interview , Prove your ability Preface Let's start with the applicable environment , We have some frequently used data in development ( Large amount of data ) It needs to be stored . save sql Well, it's not appropriate , You know, in development, every sql sentence ...

  5. $.extends Principle of inheritance

    <script type="text/javascript"> function mixs (){ var arg = arguments; var i = 1; ta ...

  6. shell Programming learning notes ( 8、 ... and ):Shell in if Use of judgment

    One .if The grammar of : 1. Single branch sentence structure if [ Conditional expression ]; then Instructions fi 2. Double branch sentence structure if [ Conditional expression ]; then Instruction one else Instruction 2 fi 3. Multi branch sentence structure i ...

  7. Data model model Set up 、 Generate data migration files 、 Perform data migration files

    One .model Configuration of 1. Create database 2. install pymysql 3. Modify the configuration file Database connection configuration DATABASES = {'default': {'ENGINE': 'django.db.backen ...

  8. drf4 Views and routing components

    APIView and View The difference between Whether it's View still APIView The first calls are as_view() APIView Inherited View, And executed View Medium as_view() Method , Finally, put view Back to , ...

  9. zlib__ZC

    Official website : , Download all versions : ZC: I downloaded it zlib-1.2.3.tar.gz and  zlib-1.2. ...

  10. SpringInAction--SpringMvc advanced technology (servlet、filter、multipart)

    I learned from the front spirng Some configuration of , as well as web Knowledge of , Today, I'm learning about spring More commonly used advanced technologies ... First of all, let's introduce what is servlet Well ( Here comes Wikipedia ) Servlet(Server Ap ...