Skip to main content

Git --CheetSheet=4

Interactive Rebase :

1. git rebase -i HEAD~4  #Interactive rebase to edit last 4 commits

2.
Plot :
You notice a critical error on your part. The commit where you wrote tests comes after the commit where you made the actual changes. Let's swap these 2 commits so that it looks like you wrote the tests first. Swap the 'Add tests' commit so that it comes before the 'Implement poodles' commit.


pick b3f1649 Add unicorn
pick 4b65a5a Add tests
pick f239187 Implement poodles
pick c3f863f Added a title to the homepage


3.Plot : As you're editing your commits, you notice that the commit that says 'Add tests' is a little vague, maybe you should change it to something more specific. Use the reword command to change the message of this commit.

pick b3f1649 Add unicorn
reword 4b65a5a Add tests to commit
pick f239187 Implement poodles
pick c3f863f Added a title to the homepage


4.Plot : You remember that the 'Add unicorn' commit also contains the testing changes. Since we have separate commits for adding tests for poodles it makes sense to split out the test changes into a separate commit. Tell git to stop at this commit so we can reorganize it a bit.

edit b3f1649 Add unicorn
pick 4b65a5a Added tests for poodles
pick f239187 Implement poodles
pick c3f863f Added a title to the homepage

5.Plot : After saving the interactive rebase text file, git has stopped at the 'Add unicorn' commit. The first thing we need to do is to reset back to the previous commit, so the changes in the most recent commit are back in the file and unstaged.

git reset HEAD~1

6.git rebase --continue

7.Plot :  You noticed another bug with those pesky poodles, so you've gone ahead and fixed it, making another commit in the process. Now you have 2 commits that both affect the poodles page. You should squash them into one commit to simplify your git logs.

pick b3f1649 Add unicorn
pick 4b65a5a Add tests
pick f239187 Implement poodles
squash c3f863f Add title to poodle page


8.  git stash #stash the present changes

9.  git stash list #get the list of stashes.

10. git stash apply #get the stash back

11. git stash drop #clean up the stash list.

12. git reset --hard #hard reset the last commit.

13. git stash pop #apply the stash and delete it in the stash list.

14. git stash --keep-index #stash only unstaged changes

15. git stash --include-untracked #stash also the untracked changes.

16. git stash list --list #stats on each listed files.

17. git stash show stash@{2} --patch #shows the expansion and details of second stash

18. git stash save "Added some message to stash" #lets you add name to the stash

19. git stash brach testbranch  #a new brach is created named "testbranch" from the stashed changes.

Pruning History :

1. git clone poodle first-one  #get the repo copied with another name, in this case "first-one"

2.git filter-branch --tree-filter 'git rm --cached --ignore-unmatch master_password.txt'

3.git filter-branch -f --tree-filter 'git rm --cached --ignore-unmatch master_username.txt'   #remove file from all of repo history

4.git filter-branch -f --prune-empty #remove the references of the deleted file.


Comments

Popular posts from this blog

Event Sourcing with CQRS.

  The way event sourcing works with CQRS is to have  part of the application that models updates as writes to an event log or Kafka topic . This is paired with an event handler that subscribes to the Kafka topic, transforms the event (as required) and writes the materialized view to a read store.

GraphQL microservices (GQLMS)

I'm curios of GraphQL !     -  GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015. It should be solving a problem in querying data !     -GraphQL lets you ask for what you want in a single query, saving bandwidth and reducing waterfall requests. It also enables clients to request their own unique data specifications. A case study ?!    -https://netflixtechblog.com/beyond-rest-1b76f7c20ef6 So, This is just another database technoloy ?  -  No. GraphQL is often confused with being a database technology. This is a misconception, GraphQL is a   query language   for APIs - not databases. In that sense it’s database agnostic and can be used with any kind of database or even no database at all. Source:   howtographql.com