Skip to content

Commit ed6d790

Browse files
committed
Add tabs for IC vs Non-IC when resetting dev to live
1 parent 05223db commit ed6d790

File tree

3 files changed

+124
-0
lines changed

3 files changed

+124
-0
lines changed

source/content/guides/git/05-undo-commits.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cms: [drupal, wordpress]
1212
audience: [development]
1313
product: [--]
1414
integration: [--]
15+
reviewed: "2025-01-23"
1516
---
1617

1718
Git makes it easy to reverse commits pushed to the Pantheon Dev environment.
@@ -174,6 +175,10 @@ You can revert a past commit that has been pushed to your Test or Live environme
174175
175176
You can reset your Dev environment history to match the current state of your Live environment using [Terminus](/terminus). The method in this section is destructive and should be used with caution. It does not clone the Live environment's database or files down to Dev. However, it does reset the Dev environment's codebase.
176177
178+
<TabList>
179+
180+
<Tab title="All others" id="all-others" active={true}>
181+
177182
1. Identify the most recent commit deployed to Live.
178183
179184
1. Run the command below to overwrite the history on Dev's codebase to reflect Live (replace `<site>` with your site's name):
@@ -183,6 +188,30 @@ You can reset your Dev environment history to match the current state of your Li
183188
git push origin master -f
184189
```
185190
191+
</Tab>
192+
193+
<Tab title="Integrated Composer" id="integrated-composer">
194+
195+
<Alert title="Note" type="info">
196+
197+
We've adjusted the following steps for [Integrated Composer sites](/guides/integrated-composer), so that you reset history to the **second** to last commit hash on the Live environment, rather than the first - to avoid resetting dev's history to a build artifact.
198+
199+
</Alert>
200+
201+
1. Identify the **second** most recent commit deployed to Live.
202+
203+
1. Run the command below to overwrite the history on Dev's codebase to reflect Live (replace `<site>` with your site's name):
204+
205+
```bash{promptUser: user}
206+
git reset --hard `terminus env:code-log <site>.live --format=string | grep -m2 'live' | tail -n 1 | cut -f 4`
207+
git push origin master -f
208+
```
209+
210+
</Tab>
211+
212+
</TabList>
213+
214+
186215
## What if Dev Is Behind Test and Live?
187216
188217
This happens if you **reset** Dev to an earlier commit, rather than using **revert**. You must make a commit on Dev to re-sync the environments. This will also get the commit history between the environments to match. The commit you use can be trivial, such as a space or extra line added to a comment within a file. You'll see the commit available for deployment on Test, and then on Live after you commit the change.

source/content/terminus/03-examples.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cms: [drupal, wordpress]
1414
audience: [development]
1515
product: [terminus]
1616
integration: [--]
17+
reviewed: "2025-01-23"
1718
---
1819

1920
This section provides information on how to apply updates, deploy code, switch upstreams, and install Drush and WP-CLI with Terminus, as well as information on command structure and automatic site and environment detection.
@@ -281,6 +282,11 @@ There are a few scenarios where it may be useful to reset your Dev environment (
281282

282283
- The Dev environment has been seriously corrupted and you would like to cleanly reset it to Live.
283284

285+
286+
<TabList>
287+
288+
<Tab title="All others" id="all-others" active={true}>
289+
284290
Follow the steps below to reset Dev to Live.
285291

286292
1. Clone the site's codebase to your local machine if you have not done so already (replace `awesome-site` with your site name):
@@ -330,6 +336,69 @@ Follow the steps below to reset Dev to Live.
330336

331337
The Site Dashboard will open when the reset procedure completes.
332338

339+
</Tab>
340+
341+
<Tab title="Integrated Composer" id="integrated-composer">
342+
343+
Follow the steps below to reset Dev to Live.
344+
345+
<Alert title="Note" type="info">
346+
347+
We've adjusted the following script for [Integrated Composer sites](/guides/integrated-composer), so that you reset history to the **second** to last commit hash on the Live environment, rather than the most recent - to avoid resetting history to a build artifact.
348+
349+
</Alert>
350+
351+
1. Clone the site's codebase to your local machine if you have not done so already (replace `awesome-site` with your site name):
352+
353+
```bash{promptUser: user}
354+
terminus connection:info awesome-site.dev --fields='Git Command' --format=string
355+
```
356+
357+
1. Automate the procedure for resetting Dev to Live by downloading the following bash script:
358+
359+
<Download file="ic-reset-dev-to-live.sh" />
360+
361+
```bash
362+
#!/bin/bash
363+
364+
#Authenticate Terminus
365+
terminus auth:login
366+
367+
#Provide the target site name (e.g. your-awesome-site)
368+
echo 'Provide the site name (e.g. your-awesome-site), then press [ENTER] to reset the Dev environment to Live:';
369+
read SITE;
370+
371+
#Set the Dev environment's connection mode to Git
372+
echo "Making sure the environment's connection mode is set to Git...";
373+
terminus connection:set $SITE.dev git
374+
375+
#Identify the second most recent commit deployed to Live and overwrite history on Dev's codebase to reflect Live
376+
echo "Rewriting history on the Dev environment's codebase...";
377+
git reset --hard `terminus env:code-log $SITE.live --format=string | grep -m2 'live' | tail -n 1 | cut -f 4`
378+
379+
#Force push to Pantheon to rewrite history on Dev and reset codebase to Live
380+
git push origin master -f
381+
382+
#Clone database and files from Live into Dev
383+
echo "Importing database and files from Live into Dev...";
384+
terminus env:clone-content $SITE.live dev
385+
386+
#Open the Dev environment on the Site Dashboard
387+
terminus dashboard:view $SITE.dev
388+
```
389+
390+
1. Execute the script from the command line within the root directory of your site's codebase:
391+
392+
```bash{promptUser: user}
393+
sh /PATH/TO/SCRIPT/reset-dev-to-live.sh
394+
```
395+
396+
The Site Dashboard will open when the reset procedure completes.
397+
398+
</Tab>
399+
400+
</TabList>
401+
333402
## Switch Upstreams
334403

335404
Every site has an assigned upstream to deliver [one-click updates](/core-updates) in the Pantheon Site Dashboard. Terminus can be used to manage this site-level configuration. There are a few scenarios where it may be useful to change a site's upstream:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
#Authenticate Terminus
4+
terminus auth:login
5+
6+
#Provide the target site name (e.g. your-awesome-site)
7+
echo 'Provide the site name (e.g. your-awesome-site), then press [ENTER] to reset the Dev environment to Live:';
8+
read SITE;
9+
10+
#Set the Dev environment's connection mode to Git
11+
echo "Making sure the environment's connection mode is set to Git...";
12+
terminus connection:set $SITE.dev git
13+
14+
#Identify the second most recent commit deployed to Live and overwrite history on Dev's codebase to reflect Live
15+
echo "Rewriting history on the Dev environment's codebase...";
16+
git reset --hard `terminus env:code-log $SITE.live --format=string | grep -m2 'live' | tail -n 1 | cut -f 4`
17+
18+
#Force push to Pantheon to rewrite history on Dev and reset codebase to Live
19+
git push origin master -f
20+
21+
#Clone database and files from Live into Dev
22+
echo "Importing database and files from Live into Dev...";
23+
terminus env:clone-content $SITE.live dev
24+
25+
#Open the Dev environment on the Site Dashboard
26+
terminus dashboard:view $SITE.dev

0 commit comments

Comments
 (0)