DEV Community

abbazs
abbazs

Posted on • Edited on

1 1

GIT recipes

How to cherry pick a file from another branch in to current branch?

git checkout <other_branch_name> <files/to/grab in/list/separated/by/spaces> -p

example:

git checkout mybranch config/important.yml app/models/important.rb -p
Enter fullscreen mode Exit fullscreen mode

How to list branches by creation date?

git for-each-ref --sort='-authordate'
Enter fullscreen mode Exit fullscreen mode

What is the difference between git fetch and git pull?

  1. git fetch pull only the meta data from remote. Good to know without actually pulling data locally.
  2. git pull pulls the difference from remote. So first do a git fetch understand the difference and then do the pull only when ready.

How to get the status of all the repositories in a directory?

for d in */; do 
    if [ -d "$d/.git" ]; then 
        echo "$d"
        cd "$d"
        git status
        cd ..
    fi 
done
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (1)

Collapse
 
lakuapik profile image
David Adi Nugroho

a tip for you, run this on your terminal:

$ man giteveryday

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay