Created
January 10, 2021 17:21
-
-
Save milosh-96/a097cdd1863b4c3fd8b3a35b016ea382 to your computer and use it in GitHub Desktop.
Git commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 Resetting work | |
git pull origin dev // ensure you have latest code from the remote repo (unless you want to do something with old code) | |
git status // ensure you commited all changes | |
git reset --hard // this will reset code to the last commit | |
git reset --hard <commit id> // this will reset code to specific commit | |
git pull origin dev // just confirm everything is up-to-date. | |
git status // ensure there are not unstaged files something like that | |
#2 Pushing code | |
git add . // add all files; git add app/Category.php, only specific file // | |
git commit -m "<description of what's changed>" // commit changes to local repo // | |
git push origin dev // push changes to remote repo - to dev branch // | |
// Origin can be whatever name you like. When you clone repo it's default name. But if you manually "link" remote repo you pick any name you want. Also, you can have multiple origins // | |
#3 Switching branches (current branch: dev) | |
git pull origin dev // ensure you have latest code from remote repo | |
git status // ensure you commited all work | |
git checkout eval // we are now on eval | |
git pull origin eval // ensure you have latest code from eval // | |
It's very important that if you create new files/folders you commit before switching branches. Otherwise, if file test.php is supposed to be only on dev branch, those files/folders won't be "deleted" when you switch to eval. | |
#4 Merging (current branch: dev, you intend to merge to eval) | |
These commands are in the best case scenario. | |
(follow #3) | |
git merge dev // we merged all files that are different on dev // | |
#4.1 Fixing merge conflicts | |
... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment