DEV Community

Marco
Marco

Posted on β€’ Edited on

1

Git πŸ§žβ€β™‚οΈ cheatsheet

this is a work in progress, I'll keep this list updated... hopefully 😜


Squash

(make the 2+ last commits merge in 1)
the last commits changes will move in the previous one

git rebase -i HEAD~4 you will see only last 4 commits
todo: example 1
change in f any commits you may want to squash like this:
todo: example 2

Move your local one step back

( see changes made on last commit as not staged, this is amazing for review changes made on the last commit)
git reset HEAD~1
If you want to make apply this status use
git reset β€”hard

Edit last commit message

will open vi and allow you to edit the message
git commit --amend

Reset to a specific commit

  1. see in details list of changes git reflow
  2. move your local to a specific hash git reset [hash]

Somebody else code has been merged an now you have conflict with the code bases

( Apply changes made by somebody else and then add your changes, you may need to solve conflict )
git rebase dev

Force checkout to a specific branch

git reset --hard origin/feat/branch-to-force

Delete branch

git branch -D feat/branch-to-delete

Rename branch

git branch -m feat/new-name-branch

VI essentials commands

Vi start in command mode,

  • for edit mode press I key (exit edit mode with ESC key)
  • for save and exit ESC then :wq
  • for exit without save ESC then :q

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❀️