[Git] 09. Remote

Clone

  • Add remote end-point

    $ git remote add origin https://github.com/KarateJB/Test.git
  • Clone

    git clone

Push

  • Push with setting remote upstream branch
    $ git push -u origin {brach_name_for_remote}

Pull

git pull equals to

  1. git fetch
  2. git merger

Pull remote branch

$ git checkout --track origin/<branch>
$ git pull

Pull by rebase (Which will not create a new commit for merging)

$ git pull --rebase

Syncing a fork

$ git fetch upstream
$ git checkout master
$ git merge upstream/master

[Git] 08. Stash

While we would like to switch our job to other branch and save current codes immediatly

Use reset

$ git add --all
$ git commit -m "Temporaryly commit, but not completed..."
```

then after doing something... we discard the last commit by rest.

$ git reset HEAD^ –hard



## Use Stash

While we have not staged current modified codes, use `stash` to save them temporaryly.

$ git stash


> If you want to stash the untracked files as well
```
$ git stash -u

  • List stash

    $ git stash list
  • POP the stash (Which will remove the stash after apply it on the same branch)

    $ git stash pop stash@{1}
  • Apply the stash(Which will not remove the stash after apply it)

    $ git stash apply stash@{1}

If the specified name of stash is not given, the latest stash will be applied

  • Remove stash
    $ git stash drop stash@{1}

[Git] 07. Tag

Tag

Create lightweight tag (for private or temporary purpose)

$ git tag {tag_name} {sha-1_code}
```

## Create annotated tag (for release or milestones)

$ git tag {tag_name} {sha-1_code} -a -m “some comments for annotated tag…”


## List tags

$ git tag -l


## Delete tag

$ git tag -d {tag_name}


## Use alias to create tag

$ git config alias.XXXX ‘!git tag MyTag-$(date +”%Y-%m-%d_%H-%M-%S”)’
$ git XXXX {sha-1_code}
`