git push -u origin feature_branch_name
git fetch
git checkout test
If that fails try:
git checkout -b test origin/test
This will only work if you have a local copy of the remote branch.
git push origin :feature-branch # Note the colon before the feature branch name.
git submodule foreach --recursive git checkout master
git submodule foreach git pull
git submodule deinit submodule-name
git rm submodule-name
git rm --cached submodule-name
rm -rf .git/modules/submodule-name # Linux
rm -Rf .git/modules/submodule-name # OS X
git reset <hash>
This will preserve current state of files, but git will consider them modified.
git reset --hard <hash>
Use with caution. You will lose all local modifications.
git reset --hard master@{"2014-08-26 13:15"}
Use with caution. You will lose all local modifications.
git checkout -- .
git fetch origin
git reset --hard origin/master
git push --force origin [branch]
Use with EXTREME caution.
git tag -l
git checkout tags/<tag_name>
git tag -a v1.4 -m 'my version 1.4'
git tag -a v1.2 -m 'version 1.2' <hash>
git push --tags
git push origin <tag_name>
git tag -d release01 # Deletes it locally
git push origin :refs/tags/release01 # Deletes it remotely
git push origin :refs/tags/<tagname>
git tag -fa <tagname>
git push origin master --tags
Useful if a lot of files change, but only a few are in conflict. Sometimes the files in conflict are hard to find with a simple git log
command.
git diff --name-only --diff-filter=U
If you know the file name and path:
file="path/to/file/file_name.py"
git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
git clean -f -n
git clean -f
git clean -f -d
git clean -f -X
git clean -f -x
git rev-list -n 1 HEAD -- path/to/filename
git checkout deletingcommitid^ -- path/to/filename
git add .
git reset -- path/to/file/that/will/not/get/added/file.txt
git commit --amend # or
git commit --amend -m "New commit message."
Assuming the branch was created off master:
git log master..
git stash apply stash@{n}
git stash save "guacamole sauce WIP"
git stash apply stash^{/guacamo}
git stash -u
git stash clear
git diff mybranch master -- path/to/myfile.py
Run this in the branch you want to compare:
git diff --name-only <branch-to-compare> // List of the changed files
For example, to compare the current branch to develop
:
git diff --name-only develop
Or to choose two branches to compare:
git diff --name-only <branch-1> <branch-2>
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
git pull upstream branch_name
git pull upstream master
git subtree add --prefix path/to/directory [email protected]:user/git-project.git master --squash
git subtree pull -P path/to/directory --squash [email protected]:user/git-project.git master
- Create a new repo
- add the new repo as a remote:
git remote add new_origin [email protected]:username/project.git
- push to the new repo:
git subtree push --prefix=path/to/directory new_origin master
Git will send the contents of the folder to the new repo along with and just the relevant commits.