Skip to content

Latest commit

 

History

History
178 lines (136 loc) · 2.88 KB

Git Workflows.md

File metadata and controls

178 lines (136 loc) · 2.88 KB

Git Workflows Cheatseat

Git Workflow

Essential Git Commands: Getting Started

Initialize git repositoty:

git init

Clone git repositoty:

git clone [url]

Working with Remotes

List Remote git repositoty:

git remote -v

Add Remote to a git repositoty:

git remote add [name] [url]

Remove Remote from a Local git repositoty:

git remote rm [name]

Fetch changes from a Remote git repositoty:

git fetch [remote]

Pull changes from a Remote git repositoty:

git pull [remote] [branch]

Pushing Local changes to a Remote git repositoty:

git push [remote] [branch]

Branching and Merging

List Branch of local git repository:

git branch

Create Branch on a local git repository:

git branch [name]

Switch Branch on a local git repository:

git checkout -b [branch]

Merge another Branch on a current branch of a local git repository:

git merge [branch]

Delete Branch on a local git repository:

git branch -d [branch]

Making changes to the local git repository

Checking status:

git status

Adding changes/Stagging changed files:

git add [files/directories]

Committing changes with message:

git commit -m "[message]"

Amend Commit:

git commit --amend [commit]

Reset File Changes:

git reset [file]

Hard Reset Commit Changes:

git reset --hard [commit]

Reviewing History

Checking git logs (with details of each commit):

git log

Checking git logs (oneline for each commit):

git log --oneline

Checking git logs (Graphical View):

git log --graph

Show changes between current state and commit:

git show [commit]

Difference between current branch and given branch:

git diff [branch]

Cleanup and Maintenance

Stash changes temporarily:

git stash

Apply Stash changes temporarily:

git stash pop

Clean untracked files:

git clean -f

Advance and Miscelaneous

Rebase the current branch with provided one:

git rebase [branch]

Cherry pick:

git cherry-pick [commit]

Tagging:

𝚐𝚒𝚝 𝚝𝚊𝚐 [𝚗𝚊𝚖𝚎]

Search Log:

𝚐𝚒𝚝 𝚕𝚘𝚐 --𝚐𝚛𝚎𝚙="[𝚙𝚊𝚝𝚝𝚎𝚛𝚗]"

This list encapsulates many of the core Git commands but is not exhaustive.

Git's flexibility and depth mean there are commands and flags for various specialized scenarios, including configuration (git config), patching (git apply), and advanced merging options.

These commands form the backbone of most Git operations, facilitating version control and collaboration in software development projects.