2017-10-23 7 views
0

私はusecaseのフィッティング回答を見つけることができませんでした。確実にgit作業コピーを更新します。

私はgitを使ってawsインスタンスへの変更を配備するつもりです。たとえば、私は生産のためにマスターブランチを使用します。私は以下の通りですいずれにせよ、で作業するソリューションを考え出したと思った:

git fetch 
git checkout -f origin/<branchname> 
git pull origin <branchname> 
git submodule update --init --recursive 
git submodule update --recursive --remote 

私は、これが適切に切り離さヘッド状態を扱うだろうと思いました。それはしばらくの間働いていたようですが、最近のアップデートでは、ローカルブランチをチェックして、リモートから変更されていません。レポにここで取り外したヘッド状態の周り 修正/仕事 更新/追加した新しいサブモジュール

された端末で上記の手順を実行しているからの出力のほとんどを

[email protected]:/redacted$ git fetch 
remote: Counting objects: 22, done. 
remote: Compressing objects: 100% (22/22), done. 
remote: Total 22 (delta 7), reused 0 (delta 0) 
Unpacking objects: 100% (22/22), done. 
From redacted:redacteduser/redactedrepo 
    b1cceb5..ee34124 master  -> origin/master 
    08ec66e..ee34124 development -> origin/development 
Fetching submodule redacted/redactedsubmodule 
remote: Counting objects: 34, done. 
remote: Compressing objects: 100% (34/34), done. 
remote: Total 34 (delta 27), reused 0 (delta 0) 
Unpacking objects: 100% (34/34), done. 
From redacted:redacteduser/redactedsubrepo 
    4d52d03..7019d5a master  -> origin/master 
[email protected]:/redacted$ git checkout -f origin/master 
Note: checking out 'origin/master'. 

You are in 'detached HEAD' state. You can look around, make experimental 
changes and commit them, and you can discard any commits you make in this 
state without impacting any branches by performing another checkout. 

If you want to create a new branch to retain commits you create, you may 
do so (now or later) by using -b with the checkout command again. Example: 

    git checkout -b <new-branch-name> 

HEAD is now at ee34124... redactedcommitmessage 
[email protected]:/redacted$ git pull origin master 
From redacted:redacteduser/redactedrepo 
* branch   master  -> FETCH_HEAD 
Already up-to-date. 
[email protected]:/redacted$ git submodule update --init --recursive 
Submodule path 'redacted/redactedsubmodule': checked out '7019d5a442cc5f69e99f3434de23a646c563589a' 
[email protected]:/redacted$ git submodule update --recursive --remote 
<no output from this command> 

ので、基本的な要件は次のようになりマスターブランチ上の新しいコミットを更新していないということは何も指摘していません。ここ

[email protected]:/redacted$ git status 
HEAD detached at origin/master 
nothing to commit, working directory clean 
[email protected]:/redacted$ git checkout master 
M  redacted/redactedsubmodule 
Previous HEAD position was ee34124... redactedcommitmessage 
Switched to branch 'master' 
Your branch is behind 'origin/master' by 5 commits, and can be fast-forwarded. 
    (use "git pull" to update your local branch) 
[email protected]:/redacted$ git pull 
Updating b1cceb5..ee34124 
Fast-forward 
redactedlistoffiles 
7 files changed, 94 insertions(+), 15 deletions(-) 
create mode 100644 redactedfile1 
create mode 100644 redactedfile2 

見られるように、私はその後、いくつかのより多くのものを走ったので、レポはまだ私は、フェッチチェックアウトと言った枝を引っ張っ使用していても、後ろの5つのコミットしました。コマンドを並べ替えるか、2回続けて実行するだけですか?私はあなたが切り離さ頭の上にあり、事前

+0

なぜ分離ヘッドで作業しますか? gitのフェッチ gitのチェックアウト gitのプル起源私はその時々切り離さ理由を知らない –

+0

。今すぐ接続された状態で、私はそれがそのようにとどまることを願っています。しかし、私はまだそれが分離されて再び着陸した場合の準備が整いたいです。あなたの踏み台をもう一度つけますか? – fredlllll

+0

あなたはgitのにリモート上にある場所を与えるので、それが外れています: ない:起源/ -f Gitのチェックアウトが、Gitチェックアウト、ノーO-Fも起源/ –

答えて

1

おかげで、あなたがする必要はありません誰かが答えを知っている願っています:

git fetch
git checkout <branchname>
git pull origin <branchname>

あなたから「-f起源/」を削除しますチェックアウトのコマンド

関連する問題