git:git_cheatsheet
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| git:git_cheatsheet [2013/02/06 08:38] – deva | git:git_cheatsheet [2017/02/21 20:20] (current) – deva | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======GIT CheatSheet====== | ======GIT CheatSheet====== | ||
| + | |||
| + | =====See diff between local commits and remote master===== | ||
| + | < | ||
| + | git diff master origin/ | ||
| + | </ | ||
| + | |||
| + | =====Pull from origin and overwrite local changes===== | ||
| + | < | ||
| + | git reset --hard; git pull -Xtheirs | ||
| + | </ | ||
| + | Useful if you have local changes that you do no longer need. | ||
| + | |||
| =====Mark file as ' | =====Mark file as ' | ||
| This will ignore the file on all commits using the -a argument. | This will ignore the file on all commits using the -a argument. | ||
| Line 36: | Line 48: | ||
| ====Create==== | ====Create==== | ||
| < | < | ||
| + | # create tag locally: | ||
| git tag -a v1.4 -m ' | git tag -a v1.4 -m ' | ||
| + | |||
| + | # push tag to server: | ||
| + | git push –-tags | ||
| </ | </ | ||
| Line 54: | Line 70: | ||
| </ | </ | ||
| - | ====Push==== | + | ====Delete==== |
| - | By default, the ‘git push’ command will not transfer tags to remote servers. To do so, you have to explicitly add a –-tags to the ‘git push’ command. | + | < |
| + | # delete tag locally: | ||
| + | git tag -d v1.0 | ||
| + | |||
| + | # push tag deletion | ||
| + | git push origin : | ||
| + | </ | ||
| =====Branches===== | =====Branches===== | ||
| Line 63: | Line 85: | ||
| </ | </ | ||
| + | ====Create branch==== | ||
| + | Create and switch to: | ||
| + | < | ||
| + | git checkout -b [branchname] | ||
| + | </ | ||
| + | |||
| + | Just create: | ||
| + | < | ||
| + | git branch [branchname] | ||
| + | </ | ||
| + | |||
| + | Push to server: | ||
| + | < | ||
| + | git push -u origin [branchname] | ||
| + | </ | ||
| ====Switch to branch==== | ====Switch to branch==== | ||
| < | < | ||
| Line 68: | Line 105: | ||
| </ | </ | ||
| + | ====Delete branch==== | ||
| + | < | ||
| + | git branch -d branchname | ||
| + | git push origin --delete branchname | ||
| + | </ | ||
| + | ====Fecth branches from server==== | ||
| + | < | ||
| + | git fetch --all | ||
| + | </ | ||
| =====CVS 2 GIT===== | =====CVS 2 GIT===== | ||
| < | < | ||
| Line 86: | Line 132: | ||
| git --bare init | git --bare init | ||
| git update-server-info | git update-server-info | ||
| - | cd / | ||
| - | / | ||
| chown -R apache: | chown -R apache: | ||
| </ | </ | ||
| Line 97: | Line 141: | ||
| </ | </ | ||
| NOTE: If this is done by the usual 'git push' command, a 'No refs in common and none specified; doing nothing.' | NOTE: If this is done by the usual 'git push' command, a 'No refs in common and none specified; doing nothing.' | ||
| + | |||
| + | =====Set up repository mirror===== | ||
| + | From: https:// | ||
| + | < | ||
| + | # Create a bare clone of the repository. | ||
| + | git clone --bare https:// | ||
| + | |||
| + | # Mirror-push to the new repository. | ||
| + | cd old-repository.git | ||
| + | git push --mirror https:// | ||
| + | </ | ||
| + | |||
| + | =====Move single directory to its own repository===== | ||
| + | http:// | ||
| + | |||
| + | =====Replace email address in commits and tags====== | ||
| + | https:// | ||
| + | |||
| + | NOTE: The way the push command is performed is important in order to overwrite bot commits and tags. | ||
git/git_cheatsheet.1360136313.txt.gz · Last modified: by deva
