-
Notifications
You must be signed in to change notification settings - Fork 12
Git Commands Memo
Stanislav Osipov edited this page May 6, 2020
·
20 revisions
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 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.
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