> CURRENT_BRANCH="$(git branch &>/dev/null; if [ $? -eq 0 ]; then echo "$(git branch | grep '^*' |sed s/\*\ //)"; fi)"
Does Your 5th line is missing closing bracket or maybe I don't understand something? Pozdrawiam, -- Łukasz Siwiński 17-08-2012 23:39, "Tom Roche" <tom_ro...@pobox.com> napisał(a): > > Tom Roche Monday, May 7, 2012 10:09:29 AM UTC-7 > >> How to [easily] overwrite managed files in an existing directory > >> with the latest versions from a remote branch/repo, without merging > >> or whack-n-clone? > > as defined @ top of thread > https://groups.google.com/d/topic/git-users/vYnSjP5ueXs/discussion > > Note again, I'm trying to keep it simple/easy for a group of > (relatively) new adopters who don't self-identify as software > engineers. > > Peter J Weisberg Mon, 7 May 2012 15:35:02 -0700 (PDT) > > git fetch origin > > git reset --hard origin/master > > > DON'T use `reset` if there's anything in the local branch history > > that you don't want to lose. `reset` affects the history of the > > current branch, not just the working files. > > Belated thanks for that advice! which got us started. Since then > another workflow has evolved, about which I'd appreciate comments/ > warnings, especially > > * warnings of the form, "under [plausible circumstances], your > workflow produces [significant harms]" > > * pointers to existing tools handle this usecase better > > 0 User switches remote to the desired repo. > > 1 User runs bash script (follows my .sig to end of post) to see what > if any changes have been made in remote. > > 2 If user wants to adopt changes, s/he does > > $ git merge --no-commit [${TARGET}] > > Seems to work, but is this likely to "bite back"? or is there > A Better Way(tm) to do this? > > TIA, Tom Roche <tom_ro...@pobox.com>---script follows to end of post--- > > #!/usr/bin/env bash > # adapted from > https://github.com/ddollar/git-utils/blob/master/git-incoming > > # TODO: usage > # TODO: add --verbose, turn off echo-ing by default > > TARGET="${1}" > CURRENT_BRANCH="$(git branch &>/dev/null; if [ $? -eq 0 ]; then echo > "$(git branch | grep '^*' |sed s/\*\ //)"; fi)" > echo -e "CURRENT_BRANCH=${CURRENT_BRANCH}" > > if [[ -z "${CURRENT_BRANCH}" ]]; then > echo -e 'ERROR: cannot determine current branch' > exit 1 > else > if [[ -z "${TARGET}" ]]; then > TRACKING_REPO="$(git config branch.${CURRENT_BRANCH}.remote)" > echo -e "TRACKING_REPO=${TRACKING_REPO}" > if [[ -z "${TRACKING_REPO}" ]]; then > echo -e 'ERROR: cannot determine tracking repository' > exit 2 > else > REMOTE_REPO="${TRACKING_REPO}" > REMOTE_BRANCH="$(git config branch.${CURRENT_BRANCH}.merge | sed -e > 's#^[^/]*/[^/]*/##')" > TARGET="${REMOTE_REPO}/${REMOTE_BRANCH}" > echo -e "REMOTE_REPO=${REMOTE_REPO}" > echo -e "REMOTE_BRANCH=${REMOTE_BRANCH}" > echo -e "no TARGET specified by command, using TARGET=${TARGET}" > fi > fi > fi > > # payload > echo -e "Incoming changes from TARGET=${TARGET}" > # TODO: only diff if -n $(git log) > for CMD in \ > "git fetch" \ > "git log ..${TARGET}" \ > "git diff ..${TARGET}" \ > ; do > echo > echo -e "$ ${CMD}" > eval "${CMD}" > done > exit 0 > > # Note on double dots '..' above from 2nd answer @ > http://stackoverflow.com/questions/4944376/how-to-check-real-git-diff-before-merging-from-remote-branch > # > You can use various combinations of specifiers to git to see your > diffs as you desire: > > # > $ git diff remote/origin > # > This shows the incoming remote changes as deletions; any commits in > your local repository are shown as additions. > > # > $ git diff ...remote/origin > # > Shows incoming remote changes as additions; the triple-dot excludes > changes committed to your local repository. > > # > $ git diff ..remote/origin > # > Shows incoming remote changes as additions; the double-dot includes > changes committed to your local repository as deletions (since they are not > yet pushed). > > -- > You received this message because you are subscribed to the Google Groups > "Git for human beings" group. > To post to this group, send email to git-users@googlegroups.com. > To unsubscribe from this group, send email to > git-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/git-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To post to this group, send email to git-users@googlegroups.com. To unsubscribe from this group, send email to git-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/git-users?hl=en.