git

- 1 min

update repo

show remote url

git remote -v

modify remote url

git remote set-url <name: e.g. upstream> <url>

fetch upstream

git remote add upstream <git url>
git fetch upstream fetch all branches
git checkout master
git rebase upstream/master
git push -f origin master
git checkout master
git remote add upstreamname/repo https://myname@bitbucket.org/upstreamname/repo.git
git fetch upstreamname/repo
git merge remotes/upstreamname/repo/master

revert uncommitted changes including files and folders

# Revert changes to modified files   
git reset --hard

# Revert changes of a single file  
git checkout HEAD -- my-file.txt


# Remove all untracked files and directories. (`-f` is `force`, `-d` is `remove directories`)
git clean -fd

force local repo to be exactly the same with upstream

# this makes repo exactly the same as upstream: your commits will be eaten!   
git fetch upstream
git reset --hard upstream/master
git push origin master --force
comments powered by Disqus
rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora