Top Banner
[email protected] GIT trick for panicked contributors ROME | 12 October 2017 Olivier Hallot and Xisco Faulí
15

GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

May 25, 2018

Download

Documents

dangtruc
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

[email protected]

GIT trick for panicked contributors

ROME | 12 October 2017

Olivier Hallot and Xisco Faulí

Page 2: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

LET THIS BE INTERACTIVE AND TELL US HOW YOU DEAL WITH GIT

Page 3: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

REMOTE REJECTED !

Page 4: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

4

Remote rejected!● Cause: Changes in remote not in local

● Solution:

– git pull -r (pull and rebase)

– Push your patch

Page 5: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

MERGE CONFLICT

Page 6: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

6

Merge conflict● Your local copy conflict with remote copy on same lines/files

● “<<<<<” means repository contents

● “>>>>>” means your contents

● Delete or edit the correct contents

● Commit changes

● Push your patch

Page 7: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

git pull -r does not work

Page 8: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

8

git pull -r does not work● You have local modifications not committed

● Solution 1: Delete your local work if you think it is not necessary

– git checkout -f or git reset --hard HEAD

– git pull -r

● Solution 2: save temporary with stash

– git stash

– git pull -r

– git stash pop

● Solution 3: Commit your changes if your work is done

– git commit -m “message”

– git pull -r

● Solution for panicked: copy all your modified files out of git and go to Solution 1. Copy your work back.

Page 9: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

OTHER USEFUL GIT COMMANDS

Page 10: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

10

Other useful commands

●git status●git branch●git gui●git log

Page 11: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

How to minimize headaches?

Use branches

Page 12: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

12

Use branches !● Do NOT HACK ON MASTER BRANCH

● Much harder to revert

● USE A LOCAL BRANCH !!!

● git checkout -b MyBranch

● Then make you hack, commit, push.

● If you want to desist, checkout your modified files and go back to master

● Or commit your changes and go back to master

● You can delete your flawed branch !● git branch -D MyBranch

Page 13: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

My Branch

MASTER

Delete branch

Push to gerrit

Branching

A Picture!

Page 14: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

Checking a patch by cherry picking

My Branch

MASTER

Delete branch

Approve in gerrit

Branching

TEST PATCHCherry-pick

Page 15: GIT trick for panicked contributors - LibreOffice Conference · GIT trick for panicked contributors ... Delete or edit the correct contents ... copy all your modified files out of

All text and image content in this document is licensed under the Creative Commons Attribution-Share Alike 4.0 License (unless otherwise specified). "LibreOffice" and "The Document Foundation" are registered trademarks. Their respective logos and icons are subject to international copyright laws. The use of these therefore is subject to the trademark policy.

THANK YOU!