git stash를 원격 저장소로 푸시 할 수 있습니까?
git에서 숨김을 생성하고, 원격 저장소로 숨김을 푸시하고, 다른 컴퓨터에서 숨김을 검색하고, 숨김을 적용 할 수 있습니까?
또는 내 옵션은 다음과 같습니다.
- 패치를 작성하고 다른 컴퓨터에 패치를 복사하십시오. 또는
- 부 지점을 만들고 해당 지점에 불완전한 작업을 수행 하시겠습니까?
가져 오기 등을 통해 가져올 수 없으며 미러 참조 스펙은 fetch = +refs/*:refs/*
이며 숨김은 refs/stash
전송되지 않습니다. 명시적인 refs/stash:refs/stash
것도 효과가 없습니다!
어쨌든 모든 스 태쉬를 가져 오지 않고 최신 스 태쉬 만 가져 오기 때문에 혼란 스럽습니다. 숨겨 놨다의 목록이입니다 reflog 심판의 refs/stashes
.
참고 : 방금 벨트 아래에 24 시간 더 많은 git-fu 로이 답변을 다시 작성했습니다.) 쉘 역사에서 전체 세방은 이제 3 개의 1 라이너입니다. 그러나 귀하의 편의를 위해 압축하지 않았습니다.
이런 식으로, 나는 당신이 맹목적으로 복사 / 붙여 넣기 대신에 내가 어떻게했는지를 볼 수 있기를 바랍니다.
여기 단계적으로 있습니다.
~ / OLDREPO에 숨김이 포함 된 소스라고 가정하십시오. 숨김이없는 테스트 복제본을 만듭니다.
cd ~/OLDREPO
git clone . /tmp/TEST
임시 보관소로 모든 숨김을 푸시하십시오.
git send-pack /tmp/TEST $(for sha in $(git rev-list -g stash); \
do echo $sha:refs/heads/stash_$sha; done)
수신 측에서 루프하여 숨김으로 다시 변환하십시오.
cd /tmp/TEST/
for a in $(git rev-list --no-walk --glob='refs/heads/stash_*');
do
git checkout $a &&
git reset HEAD^ &&
git stash save "$(git log --format='%s' -1 HEAD@{1})"
done
당신이 할 경우 임시 지점 정리
git branch -D $(git branch|cut -c3-|grep ^stash_)
자식 숨김 목록을 작성하면 다음과 같이됩니다.
stash@{0}: On (no branch): On testing: openmp import
stash@{1}: On (no branch): On testing: zfsrc
stash@{2}: On (no branch): WIP on sehe: 7006283 fixed wrong path to binary in debianized init script (reported as part of issue
stash@{3}: On (no branch): WIP on debian-collab: c5c8037 zfs_pool_alert should be installed by default
stash@{4}: On (no branch): WIP on xattrs: 3972694 removed braindead leftover -O0 flag
stash@{5}: On (no branch): WIP on testing: 3972694 removed braindead leftover -O0 flag
stash@{6}: On (no branch): WIP on testing: db9f77e fuse_unmount_all could be starved for the mtx lock
stash@{7}: On (no branch): WIP on xattrs: db9f77e fuse_unmount_all could be starved for the mtx lock
stash@{8}: On (no branch): WIP on testing: 28716d4 fixed implicit declaration of stat64
stash@{9}: On (no branch): WIP on emmanuel: bee6660 avoid unrelated changes
원래 저장소에서 동일한 모양
stash@{0}: WIP on emmanuel: bee6660 avoid unrelated changes
stash@{1}: WIP on testing: 28716d4 fixed implicit declaration of stat64
stash@{2}: WIP on xattrs: db9f77e fuse_unmount_all could be starved for the mtx lock
stash@{3}: WIP on testing: db9f77e fuse_unmount_all could be starved for the mtx lock
stash@{4}: WIP on testing: 3972694 removed braindead leftover -O0 flag
stash@{5}: WIP on xattrs: 3972694 removed braindead leftover -O0 flag
stash@{6}: WIP on debian-collab: c5c8037 zfs_pool_alert should be installed by default
stash@{7}: WIP on sehe: 7006283 fixed wrong path to binary in debianized init script (reported as part of issue #57)
stash@{8}: On testing: zfsrc
stash@{9}: On testing: openmp import
나는 파티에 조금 늦었지만, 나는 이것에 관해 나에게 도움이되는 것을 발견했다고 믿으며, 귀하의 상황이 같거나 비슷한 경우에도 당신에게도 도움이 될 수 있습니다.
자체 지사에서 기능을 작성 중입니다. 지점은 마스터로 합병되지 않고 완료 될 때까지 밀리지 않았거나 대중에게 편안하게 보여줄 수 있다고 커밋했습니다. 따라서 비 단계적 변경 사항을 다른 컴퓨터로 전송하려고 할 때 수행하는 작업은 다음과 같습니다.
- "
[non-commit] FOR TRANSFER ONLY
" 와 같은 커밋 메시지를 사용하여 전송하려는 컨텐츠 가있는 커밋을 수행 하십시오. - 다른 컴퓨터에 로그인하십시오.
그런 다음 수행하십시오.
git pull ssh+git://<username>@<domain>/path/to/project/ rb:lb
The URL might differ for you if you access your repository in a different way. This will pull changes from that URL from the remote branch "rb" into the local branch "lb". Note that I have an ssh server running on my own computer, and am able to access the repository that way.
git reset HEAD^
(implies--mixed
)This resets the HEAD to point to the state before the "[non-commit]" commit.
From git-reset(1): "--mixed
: Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) [...]"
So you will have your changes to the files in the end, but no commits are made to master and no need for a stash.
This will however require you to git reset --hard HEAD^
in the repository in which you made the "[non-commit]", since that commit is garbage.
It's a little late, but this answer might help someone. I wanted to know this because I wanted to be able to push an in-progress feature/bug/whatever and work from the same point on another computer.
What works for me is to commit my in-progress code (in a branch that I'm working on alone). When I get to my other computer, do a pull, then undo the commit with:
git reset --soft HEAD^
Continue working as you were, with all your in-progress changes there, uncommitted, and unstaged.
Hope it helps.
There seems to be a very neat trick to solve this. you can use git diff > file.diff
(and commit the file) , then restore the changes using git apply file.diff
(from anywhere) to achieve the same result.
This was explained here as well.
I'd go with second approach although no idea why you can't commit it to master/featured branch . It is possible to do cherry-picking too.
AFAIK the whole idea of stash is to hide something not-so-important under the local carpet. Nobody should know about your favorite crap ;-) The only "but" is: But if I develop on a couple of workstations? Then scp
is way better.
The following does not work with the stash, but with the uncommitted changes in the working dir. It creates a branch, autocommits all current changes, and pushes to the remote:
commit_and_push_ ( ) {
# This will:
# 1. checkout a new branch stash-XXX
# 2. commit the current changes in that branch
# 3. push the branch to the remote
local locbr=${1:-autostash-XXX}
git checkout -b $locbr
git add .
git commit -a -m "Automatically created commit"
git push origin $locbr
echo "Autocommitted changes in branch $locbr ..."
}
Use like:
commit_and_push_ my-temp-branch
commit_and_push_
Just use Dropbox like this guy did. That way you don't have to worry about pushing stashes since all your code would be backed up.
'Programing' 카테고리의 다른 글
면접 질문 : WPF 개발자 (0) | 2020.05.18 |
---|---|
ViewPager를 사용하는 android.app 조각 대 android.support.v4.app? (0) | 2020.05.18 |
기본 이미지가 업데이트 된 경우 도커 컨테이너를 자동으로 업데이트하는 방법 (0) | 2020.05.18 |
C ++ 코드에서`int`를 사용해야하는 이유가 여전히 있습니까? (0) | 2020.05.18 |
Chrome 개발자 도구의 스타일 패널에서 CSS 변경 사항을 저장하는 방법 (0) | 2020.05.18 |