How do I discard changes in my working copy that are not in the index? git stash save --keep-index --include-untracked You don't need to include --include-untracked if you don't want to be thorough about it. or drop the stash git stash drop or all unstaged files in current working directory use: git checkout -- .… Continue reading Git tips
Category: Git
gitsubree usage
Basic commands about subtree git subtree add --prefix=<prefix> <commit> git subtree add --prefix=<prefix> <repository> <ref> git subtree pull --prefix=<prefix> <repository> <ref> git subtree push --prefix=<prefix> <repository> <ref> git subtree merge --prefix=<prefix> <commit> git subtree split --prefix=<prefix> [OPTIONS] [<commit>] 1. Add subtree For example git remote add -f ios git@github.com:zhihuitang/stockholm-rail-ios.git -f: Pull immediately after adding Add… Continue reading gitsubree usage
Adding an existing project to GitHub using the command line
Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub. Open Terminal. Change the current working directory to your local project. Initialize the local directory as a Git repository. Add the… Continue reading Adding an existing project to GitHub using the command line
git squash
1. Add a global "squash" alias from bash git config --global alias.squash '!f(){ git reset --soft HEAD~${1} && git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"; };f' 2. ~/.gitconfig should now contain this alias: [alias] squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f" 3. Usage git… Continue reading git squash