Categories
Workflow

Git Track new branch

Commit changes to new local branch, then:

git push -u origin new_branch_name

Categories
Workflow

Remove Files from Git Repo

From: https://medium.com/better-programming/how-to-remove-committed-files-from-git-version-control-b6533b8f9044


  1. Create a .gitignore file, if you haven’t already
  2. Edit .gitignore to match the file/folder you want to ignore
  3. Execute the following command: 
    git rm --cached path/to/file
  4. Git will list the files it has deleted. The --cached flag should be used if you want to keep the local copy but remove it from the repository.
  5. Verify that these files are being deleted from version control using git status
  6. Push the changes to the repository

After completing these steps, those files should be removed from version control but not removed from any local machine. Any other developer which pulls again after you pushed your changes should have no issues.

How To Remove Committed Files From Git Version Control

Categories
Workflow

Rename Default Git Branch

Rename on Github first.

Then:

git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
Categories
Workflow

Squashing Git Commits

Assuming none pushed to origin.

git rebase -i HEAD~n where n is number of recent commits to squash.

Vim will show commits from oldest to newest.

  • i to enter interactive mode.
  • make changes. Esc to leave interactive mode
  • :w to write
  • : x to execute (remove space between : x. Preventing emoji render)

PICK the oldest (first line).  SQUASH the subsequent commits.

Do a similar thing with Vim to edit the new commit message (interact, save, execute)