Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Holiday Homework 🎁 🎅 🎄 #3

Open
LauWien opened this issue Dec 17, 2021 · 2 comments
Open

Holiday Homework 🎁 🎅 🎄 #3

LauWien opened this issue Dec 17, 2021 · 2 comments

Comments

@LauWien
Copy link
Owner

LauWien commented Dec 17, 2021

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.
@jkikstra
Copy link

jkikstra commented Jan 20, 2022

  • Maybe add "Clone the repository to your computer." after "Fork the repository."
  • Maybe add "open a text file, make a change, and then ... " before "Add a new change to the branch via commit. "

@LauWien
Copy link
Owner Author

LauWien commented Jan 20, 2022

Many thanks! I added your suggestions to the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants