Git Cheatsheet

Use oh-my-zsh and you only have to type 2-3 letters for each command

Here are a few important Git commands that might have been missed:

1. git init –bare: Initializes a bare repository, useful for central repositories. 2. git remote -v: Lists all remotes with their fetch and push URLs. 3. git log –oneline: Displays a compact, one-line view of the commit history. 4. git cherry-pick [commit]: Applies a specific commit to the current branch. 5. git revert [commit]: Reverts changes from a specific commit by creating a new commit. 6. git mv [file] [newfile]: Renames or moves a file in the repository. 7. git tag [name]: Adds a tag to a specific commit for versioning. 8. git clean -f: Removes untracked files from the working directory. 9. git blame [file]: Shows who modified each line in a file. 10. git bisect: Helps find a bug by performing a binary search between good and bad commits.

git stash list shows all the stashed items git stash show -p stash@{x} —name-only files changed in a particular stash git stash pop stash@{x} pop’s stash specified git checkout stash@{x} —<filename> pop’s a particular file from the mentioned stash

I use GitExtensions application, so, I dont have to remember any commands.

Got to include the -p flag for add and checkout at least… Add or revert changes in working copy using an interactive patch viewer. I use add -p nearly every time I prepare a commit.

It's missing: git stash apply which applies the stash but preserving the stash without dropping it

git cat-file -p <hashedcommit> . It is very useful to gather information about a particular commit.

It looks perfect, and thanks for sharing! If I were to add something, I’d suggest an important and useful alias to show the log cleanly and visually:

git config –global alias.clog 'log –oneline –graph'

`git switch [name]` to change branch `git switch -c [new-name]` to create and change to branch are nicer than checkout

To quickly switch back to the previous branch: git checkout -

This is a great cheat sheet for essential git commands! One thing I would add is the git fetch“ command, which downloads changes from a remote repository but does not merge them into the local branch.

git branch -m <newbranch> to rename the name of branch before publish. git stash -u is the one that I almost use daily. I use more git init,status,add and good and old push -f kk Perhaps add: git blame, git bisect Git squash? Instructif