Overwrite local staging or master with remote
Must use Git Bash.
To overwrite local master with remote:
git checkout master
git fetch --all
git reset --hard origin/master
To overwrite local main with remote "upstream"
git fetch upstream
git reset --hard upstream/main
Related cards:
Deprecated - How to Remove Unwanted Files Before Merging an Upstream Branch to Master and Staging
Deprecated method. Use this instead. See also [this](https://makandracards.com/kiat_git/485037-how-to-r...
Create local repository and push to remote
Create Local Repository
- Download GitHub for Windows or use something similar, which includes a shell
- Launch Git Shell
- In the shell, navigate to the directory with
cd
-
git init
to create a local repository
...
Set local master the same as remote repository
Setting your branch to exactly match the remote branch can be done in two steps:
git fetch origin
git reset --hard origin/master
How to work with git in an evironment with production, staging, dev servers
First, install git server in the machines. Then, install git client in local machine. After creating the remote and local repositories, the trick now is creating a hook in the remote servers to update the code change at the shell. Git hooks are sc...
How to migrate to Magento LTS with git with combined histories
Scenario
Magento 1 is end of life. I want to migrate an existing Mage repo to the latest from Magento - Long Term Support maintained by OpenMage .
Warning: the follow...
Pull from Remote Repository
When other made changes and push those changes to remote repository, we can pull those changes to our local repository. However, if a local file will be overwritten with the pull, an error will occur: “Your local changes to the following files wo...
prod log: code deployment
"git is not a deployment tool, so don't do that"
http://gitolite.com/deploy.html
Set up SSH keys
The following setup the SSH for root so we can use SSH to bitbucket when login as root.
...
How to Update a Forked Repository from Upstream
Scenario
2 to 3 remote repositories in GitHub and 2 local repositories:
- [GitHub] Go to an owner repository (eg OpenMage).
- [GitHub] Fork owner's repository (from item 1).
- [GitHub or BitBucket] Our application with custom code.
- [Loca...
Merge a GitHub Pull Request to Local Repo
When we need to test a PR in github or we want to incorporate a PR, we can checkout the PR locally.
To check out a pull request locally, use the gh pr checkout subcommand. Replace pull-request with the number, URL, or head branch of the pull requ...
When things go wrong, revert to earlier commit
When things go wrong, for example, caused by a bad commit, we need to revert back to an earlier known good commit. To identify the commit to revert to, read the commit graph carefully, pay close attention to the dots on the lines. The commit to re...