Git
####How to merge changes from original owner of a forked repo
(Basically syncing with original master)
- In terminal,
```bash
$ git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
2. Specify the new upstream
```bash
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
- Verify with
git remote -v - Now to fetch upstream changes:
git fetch upstream - Checkout local master:
git checkout master - Merge the changes:
git merge upstream/master - To force a fork to be same as upstream,
git remote add upstream /url/to/original/repo git fetch upstream git checkout master git reset --hard upstream/master git push origin master --force
Git study notes
- Check logs
git loggit log --onelinegit log --oneline --graph
- Recover deleted files
git reset --hardCan make you lose changes you made in the filesgit reset --mixedDefault flag thats used by git, it retains the altered state in current working directory.
- Branching and Checking out
git branch namegit checkout namegit log --decorate --graph --oneline --allShows commits across all branchesgit tag
- Merging
- In git, «« HEAD is the point where things branched off, and ==== marks the start of the other branch designated by »»> branch
A B C <<<<<<< HEAD D F G ======= E H >>>>>>> experimentalChanged to ``` A B C D E F G H
- In git, «« HEAD is the point where things branched off, and ==== marks the start of the other branch designated by »»> branch
Resulting in:
- 8950ccc (HEAD -> master) merged experimental
|\
| * 69d7fb4 (experimental) H | * b01c60d E -
62651d2 G -
9f95b66 F -
5683361 D / - 8d8212d C
- de5e880 B
- 5cadd5e A
```