Coder Social home page Coder Social logo

branching's Introduction

branching

The purpose of this repository is to show in the code-and-tell of the weekly MESSAGEix meeting

  • what a commit is,
  • what GitHub does if you push a commit to your branch and
  • what happens if you merge/rebase.

The goal of this code-and-tell is to deepen the understanding of what git does with different commands you give, and the impacts they have on the commit history/your branch.

To see the current commit history of the repository, please check out Insights > Network.

branching's People

Contributors

lauwien avatar

Stargazers

Wang Shan avatar

Watchers

 avatar

branching's Issues

Holiday Homework :gift: :santa: :christmas_tree:

Rebase/merge branches

  1. Fork and clone the repository to your computer.
  2. Rebase
    a. Checkout branch feature/b.
    $ git checkout feature/b
    
    b. Checkout a new branch.
    $ git checkout -b your_name/feature/b
    
    c. Open a text file, make a change and add the change to the branch via commit.
    $ git commit changed_file
    
    d. Interactively rebase your_name/feature/b with main while squashing your last commit with the commit before (mark as "squash") and dropping another commit of your preference with (mark as "drop").
    $ git rebase -i main
    
    e. Resolve the conflicts as you wish.
    f. Create a PR to main from your_name/feature/b.
    g. Check the commit history.
    h. Write in the PR description what rebase did to the commit history.
  3. Merge
    a. Do steps 2. a-c with branch feature/a.
    b. Merge main into your_name/feature/a.
    $ git merge main
    
    c. do steps 2. e-g.
    d. Write in the PR description what merge did to the commit history.

Revert/change commits

  1. Checkout branch feature/b again and checkout a new branch your_name/revert/feature/b or else.
    $ git checkout feature/b
    $ git checkout -b your_name/revert/feature/b
    
  2. Revert this commit 962ecfb.
    $ git revert 962ecfb
    
  3. Change a commit with multiple modified/added files.
    $ git rebase -i HEAD~3
    
    This shows you in the pop-up window of the interactive rebase the last three commits. This three commits should be the following now (the last hash of the revert commit differs).
    cbbda1b Modify file1 and file8, add file10
    962ecfb Modify file2
    8a3af32 Revert "Modify file2"
    
  4. Mark commit cbbda1b as "edit"
  5. Delete file10.txt and delete line 2 in file1.txt (# Another change in feature/b) so the file only has 1 line.
  6. Amend the commit and modify the commit message, since file10.txt got deleted and the changes in file1.txt won't be committed.
    $ git commit --amend
    
    The "Changes to be committed" message should look now like the following:
    # Changes to be committed:
    #     modified:   file8.txt
    
  7. Create a PR and write in the description in your own words what you did, in what situation these two commands might be helpful or if you already had a situation were this would have come in handy.

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.