Skip to content

Instantly share code, notes, and snippets.

@iscott
Last active April 17, 2021 15:49
Show Gist options
  • Select an option

  • Save iscott/757aeedc7ec3e34b510904c67f0542a2 to your computer and use it in GitHub Desktop.

Select an option

Save iscott/757aeedc7ec3e34b510904c67f0542a2 to your computer and use it in GitHub Desktop.

Revisions

  1. Ira Herman revised this gist Apr 17, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git_branches_and_merging.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,9 @@

    ### Create a branch called "my_feature_branch" and change your git to working on that branch:

    ```git checkout -b my_feature_branch```
    ```
    git checkout -b my_feature_branch
    ```

    The branch is an exact clone of what master was when you ran the command.

  2. Ira Herman created this gist Apr 17, 2021.
    40 changes: 40 additions & 0 deletions git_branches_and_merging.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # Basic workflow for git branching:

    ### Create a branch called "my_feature_branch" and change your git to working on that branch:

    ```git checkout -b my_feature_branch```

    The branch is an exact clone of what master was when you ran the command.

    Work as usual, however all edits will live in that feature branch only -- they won't affect master.

    ### If you want to throw out the changes, just git checkout master.

    * And you'll be back on the main branch with no changes

    * To get back to your feature branch: `git checkout my_feature_branch`

    ### If you want to merge your changes into the master branch:

    On the `my_feature_branch` branch:

    ```
    git add -A
    git commit -m "message goes here"
    ```

    then to merge in the changes from the jamie branch:

    ```
    git checkout master to switch back to the master branch
    git merge my_feature_branch
    ```

    You've successfully merged in your feature branch changes.
    At this point you can leave your feature branch in the git repo, or delete it to merge the history back into master.

    ### Deleting the feature branch (after changes are merged into master):

    ```
    git branch -d my_feature_branch
    ```