Skip to content

jambolo/git-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-helpers

Scripts and aliases that make git easier to use

Scripts

cpp-init-default <project>

Sets up a CMake C++ project named project in a subfolder named project and commits it to a new git repo.

git-diff-branches <branch> <branch>

Displays the differences between two branches using difftool.

git-difftool-all [path]

Displays the differences for path between the working directory and HEAD all at once using difftool rather than one at a time.

git-ffwd

Fetches and fast-forwards (if possible) all branches in the repo.

git-ffwd-all

Fetches and fast-forwards (if possible) all branches in the repo and all its submodules.

git-pull-all-repos

For all git repositories in any subdirectories, pulls all branches and tags from all remotes.

git-pull-if-needed

Pulls the current branch and updates the submodules if the local branch is behind and hasn't diverged.

git-push-wip

Creates a temporary branch named wip/${user}/${timestamp} from uncommitted changes and pushes it to origin so that it can be referenced elsewhere.

git-rebase-all <branch> <pattern>

Rebases all branches matching pattern onto branch.

For example, I do this a lot: git-rebase-all develop feature

git-remove-submodule <path>

Removes a submodule from the repo completely.

git-save-commits <commit> [new branch]

Resets the current branch to commit and retains the removed commits in a new branch named branch.

Note: The new branch name defaults to wip/${branch}-saved-${timestamp} if none is provided.

git-showtool <commit>

Shows the differences between commit and its predecessor using difftool.

git-status-all

Checks all git repositories in subdirectories, and list the ones with changes.

git-sync <branch1> <branch2>

Unifies two branches such that commits in branch1 are followed by commits in branch2.

git-uncrustify

Runs uncrustify on all modified or added c/cpp/h files in the working tree.

git-update-all

Fetches and fast-forwards all branches and submodules, and then updates all submodules.

git-update-rebase <branch>

Pulls branch and rebases the current branch on top of it.

git-update-submodule <subproject-name>

Stages and commits a submodule update with a descriptive commit message showing the subproject's commit hash.

julia-init-default <project>

Sets up a Julia project named project in a subfolder named project and commits it to a new git repo.

node-init-default <project>

Sets up a node.js NPM project named project in a subfolder named project and commits it to a new git repo.

node-init-typescript

Sets up a TypeScript node.js project with NPM in the current directory and commits it to a new git repo. Includes TypeScript, tsx, vitest, and VS Code debug configuration.

pnpm-init-default <project>

Sets up a node.js PNPM project named project in a subfolder named project and commits it to a new git repo. Includes a GitHub CI workflow.

pnpm-init-typescript

Sets up a TypeScript node.js project with PNPM in the current directory and commits it to a new git repo. Includes TypeScript, tsx, vitest, VS Code debug configuration, and a GitHub CI workflow.

rust-init-default <project>

Sets up a Rust project named project in a subfolder named project and commits it to a new git repo.

Utility Scripts

update-projects.sh

Iterates through all subdirectories with Git repositories and performs a pull and submodule update on each one. Skips the 3rdParty directory. Useful for batch updating multiple projects.

Configuration Files

my-.gitconfig

Example Git configuration file with custom settings including:

  • Core settings (preload index, file system cache, editor configuration)
  • Git LFS filter configuration
  • User identity settings
  • Diff and merge tool settings (Araxis Merge)
  • Custom git aliases for all the scripts in this repository

To use this configuration, copy it to your user directory and adjust the paths and user information as needed.

my-.npmrc

Example NPM configuration file with settings for initializing new npm projects, including:

  • Author email
  • Author name
  • Author URL
  • License type
  • Project version

Aliases

Git commands with options that I use a lot.

  • alias grevert='git checkout --': Undoes any unstaged changes to the specified files
  • alias gsquash='git rebase -i': Rewrites history
  • alias gunstage='git reset HEAD': Unstages the specified files
  • alias ggraph='git log --graph ...: Draws the branch graph the way that I like it
  • alias glog='git log ...: Formats the log the way that I like it
  • alias gamend='git commit --amend --no-edit': No-fuss amended commits

About

Scripts and aliases that make git easier to use

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors