Skip to content

Instantly share code, notes, and snippets.

@Mao8a
Last active May 1, 2020 06:01
Show Gist options
  • Save Mao8a/7379107 to your computer and use it in GitHub Desktop.
Save Mao8a/7379107 to your computer and use it in GitHub Desktop.
GIT: Usefull Commands

Git Commands

To fetch a branch, you simply need to:

git fetch origin

This will fetch all of the remote branches for you. With the remote branches in hand, you now need to check out the branch you are interested in, giving you a local working copy:

git checkout -b LocalBranch origin/RemoteBranch

completely remove all files including directories I had to run

git clean -f -d

If you want to revert changes made to your working copy, do this:

git checkout .

If you want to revert changes made to the index (i.e., that you have added), do this:

git reset

If you want to revert a change that you have committed, do this:

git revert ...
git fetch origin
git reset --hard origin/mw-install
git clean -f -d
git push -f <remote> <branch>

zip from git

git archive --format=zip HEAD > file-name.zip

Submodules

git submodule add git@github.com:twbs/bootstrap.git
git submodule update --init

How do I make Git ignore file mode (chmod) changes?

git config core.fileMode false
ssh -T git@github.com
~/.ssh/config.
Host example.com
   ForwardAgent yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment