From 0126aa2af17af50d0cbfbc7ba6eb70bd974e295b Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 13 May 2018 19:17:40 +0100 Subject: Add a section on Using branches, and expand Pushing --- README.org | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 93c3560..6d06b1d 100644 --- a/README.org +++ b/README.org @@ -122,7 +122,30 @@ From the Magit status window, press =y= to get an overview of your local branches, and those on all of the remotes. Press =q= to return to the Magit status window. -* Pushing +* Using Branches + +** Creating a new branch + +To create a new branch, from the Magit status window, press =b= and +then =c=, then select the starting point, in this case, use the +default =master=, so just press =RET=. After that enter =test-branch= +as the branch name and press =RET= once more. + +Your now working on the =test-branch= branch. At the top of the Magit +status window, you should see the branch name displayed. + +** Switching branches + +To switch branch press =b= and then =b= again. In this case, switch +back to the =master= branch, so just press =RET= when prompted for the +branch to switch to. + +* Pushing [[info:magit#Pushing][(documentation)]] + +For experimenting with pushing, switch back to the =test-branch= +branch ([[*Switching branches][notes]]). + +** Explicit pushing To push, from the Magit status window press =P=. For the purposes of this tutorial, lets push the master branch of the local repository to @@ -130,6 +153,29 @@ a branch called =test-branch= in the =test= remote. To do this, after pressing =P=, select =e= for elsewhere, then enter =test/test-branch= and press =RET=. +** Setting the upstream branch + +Explicit pushing is useful, but usually you'll be pushing to a single +main remote. When doing this, it can be useful to set the "upstream" +branch, and have Git remember this. + +Press =P= to begin pushing as before, then =u= to select the +=@{upstream}= option. When prompted for the branch, select +=test/test-branch=. + +Then, put some text in the following example block, and commit the +change ([[*Comitting][notes]]). + +#+BEGIN_EXAMPLE + +#+END_EXAMPLE + +Once you're done committing, return to the Magit status window, it +should say you're ahead of the upstream branch by one commit. + +Press =P= and then =u= as before to push this new commit. As Git has +remembered the upstream branch, you won't need to select it manually. + * Pulling * Interactive rebasing -- cgit v1.2.3