Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'git cop' alias #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

OKTAYKIR
Copy link

Useful alias when you need checkout and pull a remote git branch.

@joelparkerhenderson
Copy link
Member

Thanks!

How often do you do this command?

Would you be nearly equally happy with co-p? Your idea for composing aliases could be powerful and useful to many more aliases.

@OKTAYKIR
Copy link
Author

Hi,

Thank you. I usually use it before creating the feature branch and after merging a pull request.

@joelparkerhenderson joelparkerhenderson force-pushed the main branch 22 times, most recently from 00feb02 to 8a231a3 Compare January 10, 2022 01:29
@joelparkerhenderson joelparkerhenderson force-pushed the main branch 5 times, most recently from 3b61131 to cf22c35 Compare January 10, 2022 19:41
@joelparkerhenderson joelparkerhenderson force-pushed the main branch 11 times, most recently from 99a600e to 72ab030 Compare January 11, 2022 17:31
@nicolasff
Copy link

Interesting suggestion! I use something similar, git copum for git checkout main && git pull upstream main.
That said some repos use master instead of main so I actually have git-copum as a shell script which first detects the branch (main or master) and then runs checkout + pull upstream.

#!/bin/zsh

has_main=$(git branch -a --format '%(refname:short)' | grep -cEw '^main$')
has_master=$(git branch -a --format '%(refname:short)' | grep -cEw '^master$')

if [[ $has_main == 1 ]]; then
    git checkout main
    git pull upstream main
elif [[ $has_master == 1 ]]; then
    git checkout master
    git pull upstream master
else
    >&2 echo 'Unable to find either `main` or `master`'
    return 1
fi

I have a similar version for just pum doing git pull upstream (main|master).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants