Skip to content

byui-devops/eli-infanger-personal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Command Guide

This README is a simple guide to common Git commands with useful flags and examples.


git add (stage changes)

Stage all changes: git add .

Stage a single file: git add README.md

Useful flags: -A = stage all changes including deletions -p = stage changes interactively


git commit (save a snapshot)

Create a commit: git commit -m "Add README"

Commit and automatically stage tracked files: git commit -a -m "Quick commit"

Useful flags: -a = stage tracked files automatically --amend = edit the previous commit


git push (upload commits)

Push your branch: git push

Push and set upstream branch: git push -u origin init

Useful flags: -u = remember the remote branch --force-with-lease = safer force push


git pull (download changes)

Pull latest changes: git pull

Pull with rebase: git pull --rebase

Useful flags: --rebase = keeps commit history clean


Changing the origin URL

View current remote: git remote -v

Change origin: git remote set-url origin git@github.com:byui-devops/eli-infanger-personal


git stash (save work temporarily)

Stash changes: git stash

Restore stashed changes: git stash pop

Useful flags: -u = include untracked files list = show all stashes


git revert (undo with a new commit)

Revert the latest commit: git revert HEAD

Useful flags: --no-edit = skip editing the message


git reset (move branch pointer)

Keep changes staged: git reset --soft HEAD~1

Unstage but keep changes: git reset --mixed HEAD~1

Delete changes completely: git reset --hard HEAD~1


git log (view history)

View history: git log

Clean history view: git log --oneline --graph --decorate --all


git diff (see changes)

View unstaged changes: git diff

View staged changes: git diff --staged

Useful flags: --stat = show summary of files changed


git show (inspect a commit)

Show latest commit: git show HEAD

Show specific commit: git show

Useful flags: --stat = file summary --name-only = list changed files


Summary

This guide covers essential Git commands: add, commit, push, pull
changing origin URLs
stash, revert, reset
log, diff, show

These commands form the foundation of effective version control using Git.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors