Created
September 23, 2018 12:30
-
-
Save SauravDas90/c01175dee07b35ad6d69703bfeb8b5a0 to your computer and use it in GitHub Desktop.
Contains most useful git snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. How to merge remote master to local branch | |
git fetch | |
git rebase origin/master | |
In a nutshell: | |
git merge branchname takes new commits from the branch branchname, and adds them to the current branch. If necessary, it automatically adds a "Merge" commit on top. | |
git rebase branchname takes new commits from the branch branchname, and inserts them "under" your changes. More precisely, it modifies the history of the current branch such that it is based on the tip of branchname, with any changes you made on top of that. | |
git pull is basically the same as git fetch; git merge origin/master. | |
git pull --rebase is basically the same as git fetch; git rebase origin/master. | |
So why would you want to use git pull --rebase rather than git pull? Here's a simple example: | |
You start working on a new feature. | |
By the time you're ready to push your changes, several commits have been pushed by other developers. | |
If you git pull (which uses merge), your changes will be buried by the new commits, in addition to an automatically-created merge commit. | |
If you git pull --rebase instead, git will fast forward your master to upstream's, then apply your changes on top. | |
Accepted answer | |
up vote | |
68 | |
down vote | |
accepted | |
I found out it was: | |
$ git fetch upstream | |
$ git merge upstream/master | |
2 How do I delete a Git branch both locally and remotely? | |
You cant delete the branch you are currently working upon. | |
You need to switch to another branch | |
use git checkout <branch-name> if its fetched from origin | |
else git checkout -b <branch-name> if its created in local | |
Delete Local Branch | |
To delete the local branch use one of the following: | |
$ git branch -d branch_name | |
$ git branch -D branch_name | |
$ git push <remote_name> --delete <branch_name> | |
very important pointe regarding main | |
https://stackoverflow.com/questions/22512992/node-js-package-json-main-parameter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this was created due to fact that I wrongly checked-out a new branch instead of just switching.