Archive for the ‘git’ Category

Git tag

Add new tag: git tag -a 1.1.0 -m "Version 1.1.0"; git push –tags List tags: git tag Delete local tag: git tag -d 1.0 Delete remote tag: git push origin :refs/tags/1.0

Git checkout single file

Checkout from other branch git checkout develop /path/to/file.php Checkout from HEAD git checkout HEAD — /path/to/file.php

Hard reset of local branch to match remote

git reset –hard origin/develop

See local changes not pushed to remote

git diff origin/develop..HEAD git log origin/develop..HEAD

Remove untracked files

git clean -fd

Remove untracked file

git reset

Git using subtree

1. Adding subtree to current project git remote add mysubproject git@github.com:iaghayev/mysubproject.git   git subtree add –prefix=path/to/somedir mysubproject master 2. Committing changes to subproject from path/to/somedir folder git subtree push –prefix=path/to/somedir mysubproject master 3. Getting latest code changes from subproject git subtree pull –prefix=path/to/somedir mysubproject master

Git restore local branch deleted by mistake

  1. git reflog | grep pp-auth-r1.1 response: 592b75b 2. git branch 2.7.4-69179 592b75b

Git remote change url

git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git

Git change remote url

git remote set-url origin https://username@hostname:port/project.git