-
-
Notifications
You must be signed in to change notification settings - Fork 438
Git cheat sheet
Here are some quick use cases for users of the git command-line tool. Use this as a quick reference guide if you’re looking for specific actions.
Be sure to check out the Git in a Nutshell guide as well.
Creates a local copy of a remote branch (e.g. “untested”). This can be useful if you want to switch to another branch, as only the default branch (e.g. “merge”) is checked out by default. This creates and switches to your new local branch “untested” (based on the remote branch of the same name) and pulls in the latest changes.
git checkout --track -b untested origin/untested
git pull origin untested
If you want to stay up-to-date with the latest development you will want to pull in the latest changes from our multitheftauto/mtasa-blue repository into your local repository. There are two ways to do this.
First, create an upstream
remote:
git remote add upstream https://github.com/multitheftauto/mtasa-blue # you only need to do this line once
This will delete any commits on your local master
branch, replacing it with the upstream master.
git checkout master
git fetch upstream master
git reset upstream/master --hard
git push # --force might be needed if you wrote to master
Note that --force
will push over (and delete) any commits you have pushed to the master branch on GitHub, and so is dangerous. Only do it if you’re sure you want to get rid of commits
If you just want to merge master into your branch (so that it has the latest code, without deleting your own code):
git fetch upstream master
git merge upstream/master
Note that we also recommend you to enable “pull rebasing” so that you don’t make unnecessary merge commits.
git config --global pull.rebase true # Do this once to apply it to your user account on your computer
git config pull.rebase true # Or do this once, per repo
Sometimes you just want to discard all your local changes and reset to the latest HEAD on your GitHub remote repository. Here’s how to do it for the “merge” branch.
git fetch origin merge
git reset --hard FETCH_HEAD
More information here: git ready – pick out individual commits
If you want to check out a tag (e.g. 1.0.3-Release), do the following:
git pull
git checkout -b 1.0.3-Release tags/1.0.3-Release
Project Management
Git cheat sheet
Release Checklist
Code Review
Documentation
Contributors Guide
Style Guide
Lua API
Dev Tips
BitStream
CAccountPassword
Debug Settings
General
Testing Lua
Dependencies
MTADiag
Future Planning
CEF Versions
Windows XP Support
Things for 1.6