Skip to content

Instantly share code, notes, and snippets.

@iamsonal
Last active March 20, 2024 14:26
Show Gist options
  • Save iamsonal/d262ece0cfc39df2e4ee1a164ca8837b to your computer and use it in GitHub Desktop.
Save iamsonal/d262ece0cfc39df2e4ee1a164ca8837b to your computer and use it in GitHub Desktop.
Git Tips
URL:https://sethrobertson.github.io/GitFixUm/fixup.html
Checkout evHeroHeader.html file from "feature/events/events-record-list" branch to your working branch:
git checkout feature/events/events-record-list force-app/events/main/default/lwc/evHeroHeader/evHeroHeader.html
Pull all the files from master branch to your working branch:
git pull origin master
Reset a branch
git reset --hard origin/main
CLONE ALL REPOS
curl "https://api.github.com/users/sfdc-assets/repos?page=1&per_page=100" |
grep -e 'clone_url*' |
cut -d \" -f 4 |
xargs -L1 git clone
**PULL All Repos
ls | xargs -I{} git -C {} pull
Let's break down the command step by step:
ls: The first part of the command, ls, lists all the directories and files in the current directory. It generates a list of names.
|: This is a pipe symbol, used to redirect or pass the output of one command as input to another command.
xargs: The xargs command reads the list of names generated by ls and converts them into arguments.
-I{}: This tells xargs to replace {} with the input it receives. In our case, it will replace {} with each repository name.
git -C {} pull: This is the command that will be executed on each repository. git -C is used to run a Git command in a specific directory given as the placeholder {}. In this case, the command is pull, which fetches the latest changes from the remote repository and merges them into the current branch.
So, in summary, the command is looping over each repository in the current directory (assuming the repositories are stored as directories) and running git -C {} pull on each repository to retrieve the latest updates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment