Coder Social home page Coder Social logo

git_training's Introduction

git_training

Fork this repo to your private account

Rebasing and conflict resolution

  1. Add a commit to the main branch of your fork
    git checkout main
    echo "a commit to main" > test.txt
    git add test.txt
    git commit -m"a commit to main"
    git push
  2. Create two branches from main
    git checkout -b branch_1
    git checkout -b branch_2
  3. Push a commit on each branch (modify the same line in two different ways)
    git checkout branch_1
    echo "a commit to branch_1" > test.txt
    git add test.txt
    git commit -m "a commit from branch_1"
    git push -u origin branch_1
    
    git checkout branch_2
    echo "a commit to branch_2" > test.txt
    git add test.txt
    git commit -m "a commit from branch_2"
    git push -u origin branch_2
  4. Create a pull request from first branch to main
  5. Rebase merge the first PR (in github webgui)
  6. Rebase the second PR with main
    git rebase -i origin/main
    • After conflict resolution git rebase --continue
    • When rebasing is successful git push --force-with-lease

Commit splitting

Prep

git checkout main
git checkout -b branch_3
echo "this line should be in first commit" > test.txt
echo "this line should be in second commit" >> test.txt
git add test.txt
git commit -m "this commit needs to be split"
git push -u origin branch_3

Split

git rebase -i origin/main
# change 'pick' to 'edit' on the commit
# save and close
git reset HEAD~1
echo "this line should be in first commit" > test.txt
git add test.txt
git commit -m "first commit from split"
echo "this line should be in second commit" >> test.txt
git add test.txt
git commit -m "second commit from split"
git rebase --continue
git push

git_training's People

Contributors

c-bik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.