Skip to content

Instantly share code, notes, and snippets.

@HanjoStudy
Last active December 1, 2024 06:27
Show Gist options
  • Save HanjoStudy/866cbdcee74cb7009695090063a62206 to your computer and use it in GitHub Desktop.
Save HanjoStudy/866cbdcee74cb7009695090063a62206 to your computer and use it in GitHub Desktop.
Github reset before prod
# Option 1: Clone from github -------------------------------
# Create token in Github, use pat as password
# Use dedicated Repo PAT, owner to distribute
# Option 1: Clone from github -------------------------------
# apt-get install git-flow
# Create token in Github
git init
git config --global credential.helper store
git config --global credential.helper 'cache --timeout 7200000'
$ git credential fill
protocol=https
host=github.com
username=your_username
password=your-personal-access-token
$ git credential approve
protocol=https
host=github.com
username=your_username
password=your-personal-access-token
$ git remote add origin https://github.com/username/repository.git
$ git pull origin master
$ git add .
$ git commit -m "init"
$ git push --set-upstream origin master
chmod 600 ~/.git-credentials
# Check with
$ git config --list
# Once successful
rm ~/.git-credentials
# Create a new orphan branch
git checkout --orphan temp_branch
# Add files to new branch
git add -A
git commit -m "Initial commit"
# Delete original master branch
git branch -D master
# Rename orphan branch
git branch -m master
# Push changes (if necessary)
git push -f origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment