8

8Brackets and remote repositories

8.6

Deleting remote branches

There are currently two branches, the master branch and d-03-contact. Let’s assume that we’ve finished everything on the d-03-contact branch and we want to merge it back on to the master branch and then delete d-03-contact.

The current situation is that everything is up to date, the local and remote repositories match (this is because I just pushed all the changes to the remote at the end of the previous section).

To make sure there are no differences between the remote and local, we can do a fetch to check, click the fetch button fetch icon.

Figure 8.63 - Brackets—check local and remote are in synch

Figure 8.63   Brackets—check local and remote are in synch

The fact that there are no numbers in the git pull and git push buttons (highlighted) shows that there are no differences.

Next thing is to merge d-03-contact into the master branch locally. This is an identical process to that in § 6.7.1.

To merge branches, we must be on the receiving branch (the master branch). In Brackets switch to the master branch, click the arrow next to the selected branch in the left file tree pane and select master from the drop down:

Figure 8.64 - Brackets—switch back to master branch

Figure 8.64   Brackets—switch back to master branch

You should now be on the master branch; the 03-contact.html file will no longer be visible in the file tree:

Figure 8.65 - Brackets—on the master branch

Figure 8.65   Brackets—on the master branch

To merge the branches, again click the arrow next to the master branch in the file tree and this time click the merge icon merge icon next to d-03-contact:

Figure 8.66 - Brackets—merged d-03-contact branch

Figure 8.66   Brackets—merged d-03-contact branch

In the merge dialogue box, enter the merge message shown below:

Figure 8.67 - Brackets—merge dialogue box

Figure 8.67   Brackets—merge dialogue box

Click ok and close the merge result box (there are no conflicts).

My new commit point is [da038e3], tag the new commit point with tag: P04.

Examining the commit history now shows:

Figure 8.68 - Brackets—final commit history

Figure 8.68   Brackets—final commit history

Everything is back on the master branch (locally at least) and Brackets tells us there are six commits to push to the master branch on the remote repository.

This is because all those commits that were on the d-03-contact branch are now on the master branch (locally), but the remote repository knows nothing about them yet—hence six commits to push.

Make the push, click the git push button: push icon.

As always, in the push dialogue box make sure the send tags box is ticked, leave everything else and click ok.

Close the response box and open the remote repository in GitHub. I now have 14 commits in total on the master branch, matching the local repository (Figure 8.69):

Figure 8.69 - GitHub—updated master branch

Figure 8.69   GitHub—updated master branch

It is also showing the most recent P04 commit point [da038e3].

So that’s all good. Only thing now is to delete the d-03-contact branch, both locally and remotely.

8.6.1

Deleting the remote branch

There is one golden rule for deleting a branch in both a local and a remote repository:

ALWAYS DELETE THE REMOTE BRANCH FIRST

In Brackets switch to the d-03-contact branch. It will look like this.

Figure 8.70 - Brackets—on the redundant d-03-contact branch

Figure 8.70   Brackets—on the redundant d-03-contact branch

Make sure you are on d-03-contact (highlighted).

You can only delete the remote version of the branch that is active locally. We don’t want to delete the master branch.

Now click the git push button: push icon. This opens the push dialogue box:

Figure 8.71 - Brackets—delete remote branch

Figure 8.71   Brackets—delete remote branch

This time select delete remote branch (highlighted), leave everything else and click ok. This give the following response:

Figure 8.72 - Brackets—delete remote branch response

Figure 8.72   Brackets—delete remote branch response

Looks like it’s done it. Click ok.

Refresh the GitHub repository:

Figure 8.73 - GitHub—after d-03-contact deletion

Figure 8.73   GitHub—after d-03-contact deletion

First thing: in the tab bar it shows just one branch (highlighted). Secondly, clicking the branch button there is only the master branch in the dropdown.

We’ve deleted d-03-contact from the remote repository.

8.6.2

Deleting the local branch

This is just what we did in § 6.7.2.

In Brackets, switch back to the master branch. Click the small arrow next to the master branch in the file tree:

Figure 8.74 - Brackets—delete the local branch

Figure 8.74   Brackets—delete the local branch

Click the cross next to the d-03-contact branch in the dropdown. Click ok in the “are you sure?” dialogue box.

That’s it; the d-03-contact branch is now deleted from both the local and remote repositories.

This is the final workflow—both locally and remotely:

Figure 8.75 - final workflow

Figure 8.75   final workflow



End flourish image