SOでこの質問の多くのバリエーションを見てきましたが、探しているものはありませんでした。レポがあるとします~/MyRepo/
:
$ ls -a ~/MyRepo
code.r junk.txt .git
MyRepo
ファイルのみcode.r
が追跡され、追跡されませjunk.txt
ん。~/Dropbox/MyShare/
そして、友人が (読むためだけに) アクセスできるリモート (Dropbox など) を持っているとします。このリモコンの意図は、私のコミット済みの最新バージョンののみを含み、code.r
を含まないようjunk.txt
にすることです。私は次のことを達成しようとしています:コミットするたびに、コミット されたバージョンのcode.r
リモートを(可能であれば自動的に)更新できるようにしたい.~/Dropbox/MyShare/code.r
~/MyRepo/code.r
.gitignore
無視したい追跡されていないファイルがいくつかあり、追跡しているファイルをリモートに「プッシュ」したいだけなので、そのルートは知っていますが興味はありません。cloning
また、 intoを実行するアプローチも試しました~/Dropbox/MyShare/
が、クローン作成またはプルには常に追跡対象ファイルと追跡対象外ファイルが含まれているように見えるため、リモートが汚染されます。
~/MyRepo/.git/hooks/
私の現在の解決策は、すべての「気になるファイル」をリモートに個別にコピーするための明示的なコマンドを持つポストコミットフックを下に置くことです。「気になるファイル」が変更される可能性があり、コミット後のフックを更新する必要がないため、このソリューションは好きではありません。
~/Dropbox/MyShare/
git コマンドをいくつか組み合わせて、最後にコミットされたバージョンを自動的に利用できるようにする方法があることを願っています。にコミットするたびに、手動で「プッシュ」コマンドを 1 回実行することは気にしません~/MyRepo/
。
以下の回答の1つに基づいて試したのは次のとおりですが、まだ困惑しています。
# create my repo
mkdir foo
cd foo
git init
touch fileA fileB fileC
git add fileA
git commit -m 'new'
# now create remote
mkdir ../foo_remote
cd ../foo_remote
git init
cd ../foo
git remote add foo_remote ../foo_remote
bash-3.2$ git remote -v
foo_remote ../foo_remote (fetch)
foo_remote ../foo_remote (push)
プッシュしようとすると、次の意味のエラー メッセージが表示されます。
bash-3.2$ git push foo_remote master
Counting objects: 3, done.
Writing objects: 100% (3/3), 207 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ../foo_remote
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '../foo_remote'
私が間違っているアイデアはありますか?