1 / 3

GIT Cheat Sheet

Git is the free and open source distributed version control system that's responsible for everything GitHub related that happens locally on your computer. This cheat sheet features the most important and commonly used Git commands for easy reference.<br>https://thinkcloudly.com/

Vansh5
Télécharger la présentation

GIT Cheat Sheet

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GIT Cheat Sheet ___ By Thinkcloudly What is Git ? GitisthemostcommonlyusedVersionControlSystem.Gittracksthechangesyoumaketofiles,soyouhavea recordofwhathasbeendone,andyoucanreverttospecificversionsshouldyoueverneedto.Gitalsomakes the collaborations easier, allowing changes by multiplepeople to all be merge into one source. SETUP: Configuring user information used across all localrepositories: Configuring the name 1 Git config --global user.name “Firstname Lastname” Configuring the email 2 Git config --global user.name “Valid-email” GIT BASICS: Configuring user information, initializing and cloningrepositories Initialize an existing directory as a Git repository 1 git init Retrieve an entire repository from a hosted locationvia URL 2 git clone [url] STAGE & SNAPSHOT: Working with snapshots and the Git staging area Show the modified files in the working directory, staged for your next commit 1 git status Add a file as it looks now to your next commit (stage) 2 git add [file] Unstage a file while retaining the changes in working directory Diff of what is changed but not staged 3 git reset [file] 4 git diff Diff of what is staged but not yet committed 5 git diff --staged Commit your staged content as a new commit snapshot 6 git commit -m “[descriptive message]”

  2. 2 BRANCH & MERGE : Isolating work in branches, changing context, andintegrating changes 1git branchList your branches. a * will appear next to the currently active branch 2git branch [branch-name]Create a new branch at the current commit 3git checkoutSwitch to another branch and check it out into yourworking directory 4git merge [branch]Merge the specified branch’s history into the currentone 5git logShow all commits in the current branch’s history INSPECT & COMPARE Examining logs, diffs and object information 1git logShow the commit history for the currently active branch 2git log branchB..branchAShow the commits on branchA that are not on branchB 3git log --follow [file]Show the commits that changed file, even across renames 4git show [SHA]Show any object in Git in human-readable format 5git diff branchB...branchAShow the diff of what is in branchA that is not inbranchB SHARE & UPDATE Retrieving updates from another repository and updatinglocal repos Add a git URL as an alias 1 git remote add [alias] [url] Fetch down all the branches from that Git remote 2 git fetch [alias] Merge a remote branch into your current branch tobring it up to date Transmit local branch commits to the remote repository branch Fetch and merge any commits from the tracking remote branch 3 git merge [alias]/[branch] 4 git push [alias] [branch] 5 git pull

  3. 3 TRACKING PATH CHANGES Versioning file removes and path changes 1git rm [file]Delete the file from project and stage the removalfor commit 2git mv [existing-path] [new-path]Change an existing file path and stage the move 3git log --stat -MShow all commit logs with indication of any pathsthat moved REWRITE HISTORY Rewriting branches, updating commits and clearinghistory Apply any commits of current branch ahead of specifiedone 1 git rebase [branch] Clear staging area, rewrite working tree from specific commit 2 git reset --hard [commit] TEMPORARY COMMITS Temporarily store modified, tracked files in orderto change branches Save modified and staged changes 1 git stash List stack-order of stashed file changes 2 git stash list Write working from top of stash stack 3 git stash pop Discard the changes from top of stash stack 4 git stash drop

More Related