-
Notifications
You must be signed in to change notification settings - Fork 12
Git Commands Memo
A small article to help you with day to day Git commands and common problems.
-
git status
- Your current repository status. -
git clean -f
- Removes untracked files. -
git clean -fd
- Removes untracked files & directories. -
git reset --hard
- Discard all local changes. -
git reset --hard origin/master
- Discard all local changes & local commits. -
git add -A
- Add all untracked fiels. -
git commit -am "<commit_message>”
- Commit.
-
git checkout -b <branch_name> master
- Create feature branch of master. Master branch name is optional if currently inside the master branch. -
git checkout <branch_name>
- Switch to the branch . -
git push -u origin <branch_name>
- Push your branch to the remote repository.
-
git branch -d <branch>
- Delete a branch on your local filesystem. -
git push origin <branch>
- Delete a branch on the remote repository.
git pull --rebase origin master
- Base your commits on top of the original branch.
It is possible that a merge failure will prevent this process from being completely automatic. You will have to resolve any such merge failure and run git rebase --continue
. Another option:
-
git rebase --skip
- To bypass the commit that caused the merge failure. -
git rebase --abort
- Abort the rebase process.
Assume the following history exists and the current branch is "topic":
A---B---C topic
/
D---E---F---G master
From this point, the result of the following command git pull --rebase origin master
would be:
A'--B'--C' topic
/
D---E---F---G master
-
git push -f
- Once you are done with local rebase, you need to force push the changed branch to the remote repository.
If it's the first time you check-out a repo you need to use --init
first.
git submodule update --init --recursive
For git 1.8.2 or above, the option --remote
was added to support updating to latest tips of remote branches:
git submodule update --recursive --remote
For git 1.7.3 or above you can use
git pull --recurse-submodules
if you want to pull your submodules to the latest commits instead of the current commit the repo points to. See git-submodule for details
The solution to some well-know mistakes when working with git-flow.
-
git checkout -b new-branch
- Create a new branch that has the current state. -
git checkout master
- Go back to the branch you want to remove the un-pushed commits from. -
git reset --hard origin
- Remove the un-pushed commits from the master.
- Check the repository
.gitignore
. - Check your global
.gitignore
.
- Windows cmd
%USERPROFILE%\.gitignore
- *nix or Windows git bash:
open ~/.gitignore_global
Reliable and high-quality Unity Development service. Let's Talk!
Website | AssetStore | LinkedIn | Youtube | Scripting Reference