User Tools

Site Tools


newdevs:git:commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
newdevs:git:commands [2024/08/29 13:34] slearynewdevs:git:commands [2025/04/04 13:28] (current) – [Useful Git Commands] tmccanna
Line 52: Line 52:
   * ''git reset <nowiki>--hard HEAD</nowiki>'' --> remove last commit   * ''git reset <nowiki>--hard HEAD</nowiki>'' --> remove last commit
   * ''git reset <nowiki>--hard HEAD~2</nowiki>'' --> remove last 2 commits (increment numeral as needed)   * ''git reset <nowiki>--hard HEAD~2</nowiki>'' --> remove last 2 commits (increment numeral as needed)
 +  * ''git revert <hash>'' --> remove a specific commit from a branch that you've applied multiple commits to
   * ''git rm badfile.txt'' --> delete a file (if the file is being tracked, be sure to add a commit message indicating the file has been deleted)   * ''git rm badfile.txt'' --> delete a file (if the file is being tracked, be sure to add a commit message indicating the file has been deleted)
   * ''git show <hash>'' --> display the commit text and differences of the specified commmit   * ''git show <hash>'' --> display the commit text and differences of the specified commmit
Line 106: Line 107:
 ===== Aliases ===== ===== Aliases =====
  
-Shortens normal commands so you type less:+Shortens normal commands so you type less. You can add them one at a time from the command line:
  
 <code> <code>
Line 116: Line 117:
 </code> </code>
  
 +You can also edit ''~/.gitconfig'' to see your existing aliases.
  
 +With the above aliases, you would check out main using:
 +
 +<code>git co origin main</code>
 +
 +==== Bash Aliases ====
 +
 +Mike Rylander suggests using bash aliases so you can skip typing ''git'':
 +
 +<code>
 +# git-related contents of miker's ~/.bash_aliases
 +alias branch='git branch'
 +alias ci='git commit'
 +alias co='git checkout'
 +alias dif='git diff'
 +alias fetch='git fetch'
 +alias lg='git log --pretty=oneline'
 +alias pick='git cherry-pick'
 +alias pull='git pull'
 +alias push='git push'
 +alias stash='git stash'
 +alias status='git status'
 +alias wt='git worktree'
 +</code>
 +
 +With these bash aliases in place, you would check out main using:
 +
 +<code>co origin main</code>
newdevs/git/commands.1724952892.txt.gz · Last modified: 2024/08/29 13:34 by sleary

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.