Skip to content

Instantly share code, notes, and snippets.

@supriya-premkumar
Last active December 1, 2019 00:26
Show Gist options
  • Save supriya-premkumar/fd9a1aaacace992372fdf1eb9880b11f to your computer and use it in GitHub Desktop.
Save supriya-premkumar/fd9a1aaacace992372fdf1eb9880b11f to your computer and use it in GitHub Desktop.

Revisions

  1. supriya-premkumar revised this gist Dec 1, 2019. 1 changed file with 44 additions and 1 deletion.
    45 changes: 44 additions & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -20,4 +20,47 @@
    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    > upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
    > upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)


    **Create a new branch**
    ```
    1. git checkout master
    2. git pull origin master #updates the local master
    3. git checkout -b <feature branch>
    ```

    **Rebase**
    ```
    1. git checkout master
    2. git pull origin master
    3. git checkout <feature branch>
    4. git rebase -i master
    ```

    **Squash commits**
    ```
    5. %s/pick/s/g
    ```

    **Edit commit**
    ```
    1. git commit --amend
    ```

    **Resolve Merge Conflicts**
    ```
    1. Resolve merge conflicts
    2. git add -A
    3. git rebase --continue
    4. git push s <feature branch>
    5. <create a PR From:s/<feature branch> To: origin/master >
    6. Once the PR is merged
    a. git checkout master
    b. git pull origin master
    c. git push —delete s <feature branch> $delete remote branch
    d. git branch -D <local branch name> #delete local branch
    e. git push origin --delete <remote branch> #delete remote branch
    ```



  2. supriya-premkumar revised this gist Dec 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@
    $ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git


    3. Verify new forked remote repo added in the previous step
    3. Verify new forked remote repo addition in the previous step
    git remote -v

    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
  3. supriya-premkumar revised this gist Dec 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Configure a remote for a fork
    **Configure a remote for a fork**

    1. List configured current repository
    git remote -v
  4. supriya-premkumar revised this gist Dec 1, 2019. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,23 @@
    Configure a remote for a fork

    1. List configured current repository
    `git remote -v`
    ```
    git remote -v

    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    ```


    2. Configuring remote for a fork
    `git remote add <give- name-for-fork-repo> <forked ssh url> `
    ```
    git remote add <give- name-for-fork-repo> <forked ssh url>

    $ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

    ```

    3. Verify new forked remote repo added in the previous step
    ```
    $ git remote -v
    git remote -v

    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    > upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
    > upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
    ```

  5. supriya-premkumar created this gist Dec 1, 2019.
    23 changes: 23 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    Configure a remote for a fork

    1. List configured current repository
    `git remote -v`
    ```
    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    ```

    2. Configuring remote for a fork
    `git remote add <give- name-for-fork-repo> <forked ssh url> `
    ```
    $ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

    ```
    3. Verify new forked remote repo added in the previous step
    ```
    $ git remote -v
    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    > upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
    > upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
    ```