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 Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (1)

Collapse
 
lakuapik profile image
David Adi Nugroho

a tip for you, run this on your terminal:

$ man giteveryday

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay