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

gmergemaster? #97

Open
robnagler opened this issue Oct 10, 2023 · 4 comments
Open

gmergemaster? #97

robnagler opened this issue Oct 10, 2023 · 4 comments
Assignees

Comments

@robnagler
Copy link
Member

robnagler commented Oct 10, 2023

I think @e-carlin and @schellj have utilities like this, but I was curious about it. I think I'd like to add some more like this, e.g. for checking out a new branch based on the current branch (probably master). Thoughts?

#!/bin/bash
set -eou pipefail

_check_clean() {
    git update-index -q --ignore-submodules --refresh
    if ! git diff-index --quiet HEAD -- --ignore-submodules &> /dev/null; then
        _err unstaged changes
    fi
    if [[ $(git ls-files --exclude-standard --others) ]]; then
        _err untracked files
    fi
}

_err() {
    echo "$@" 1>&2
    return 1
}

_main() {
    _check_clean
    _update
}

_update() {
    declare c=$(git rev-parse --abbrev-ref HEAD)
    declare m=$(git remote show origin | perl -n -e 'm{HEAD branch: (\S+)} && print($1)')
    if [[ $c == $m ]]; then
        _err not on a branch, on "$m"
    fi
    git fetch --quiet origin "$m":"$m"
    git merge "$m"
}

_main "$@"
@schellj
Copy link

schellj commented Oct 13, 2023

I generally use magit in emacs to interact with git and have been for several years. There, to update and check out a new branch based on the current branch, I would enter F u (pull upstream), then b c RET some-new-branch-name (branch, create, select base, new branch name).

Of course, adding utilities is useful as well if command line is your preference.

@robnagler
Copy link
Member Author

Thanks.

I have played with magit (fairly recently), but didn't seem to "get it". Perhaps I need to increase my effort. I also was looking at interactions with github issues, which are more complicated. (I created a mapping of issues to org-mode and back in python, which is nice enough, but it wasn't really effective for project management in the end. Now I just use simply copy and paste into org mode for my own issues.)

This doesn't solve the problem for other people, but maybe that's not a problem.

@e-carlin
Copy link
Member

This is interesting. I don't have anything like it. You can see my git stuff by searching for git in here (it's messy...).

The script looks good although it would need to be tweaked for my workflow. I usually keep many untracked files around while I'm working as a reminder to clean them up when I'm done (ex data files). I also avoid merge when possible. On working branches I always do rebase (I like the linear commit history). Sometimes if there are a lot of conflicts I'll resort back to merge which makes reconciling the conflicts easier.

I've also tried magit (and gitLens in vscode) but went back to the command line. I haven't had an "aha" moment using any of the tools to make learning them worth it. The one tool I do use frequently is vc-region-history in emacs. A good tool for searching the git log and for doing diffs would be useful.

@schellj
Copy link

schellj commented Oct 16, 2023

I also prefer rebasing when possible.

I think the main value-add of magit for me is selecting and staging individual lines from all of the unstaged changes. I like to group changes into logical units and I find doing that is much easier than from the command line.

@e-carlin e-carlin removed their assignment Jun 6, 2024
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

No branches or pull requests

3 participants