User Tools

Site Tools


git_cheat_sheet

This is an old revision of the document!


Git Cheat Sheet

Resources

Try Git

git init
git config –global core.editor “atom –wait” Make Atom the default editor.
git config –global –edit Set up username & email.
git status
git add filename.txt
git commit -m “Commit message”
git log
git remote add origin https://whatever.com
git push -u origin master -u means remember these settings
git pull origin master
git diff head
git diff –staged
git reset octofamily/octodog.txt unstages a file
git checkout – octocat.txt go back to last checkout / undo
git branch ??? Show branches. ???
git branch clean_up Create new branch.
git checkout clean_up Switch branches.
git checkout -b new_branch Checkout and create branch at the same time.
git rm '*.txt' Remove local files and include the removal in the staging area.
git rm -r folder_of_cats Recursively remove all folders and files from the given directory.
git commit -a Include the deletion of local files to staging area, do the commit.
git merge clean_up
git branch -d <branch name> Delete a branch
git branch -D <branch name> Force delete a branch. Use if branch not merged.
git push
gitk A commit viewer.

Visual Studio Online

git remote add origin https://tallguy789.visualstudio.com/_git/AnotherTestProject
git push -u origin --all

Use WinMerge

Do this in the .gitconfig file.

[mergetool]
    prompt = false
    keepBackup = false
    keepTemporaries = false

[merge]
    tool = winmerge

[mergetool "winmerge"]
    name = WinMerge
    trustExitCode = true
    cmd = "/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe" -u -e -dl \"Local\" -dr \"Remote\" $LOCAL $REMOTE $MERGED

[diff]
    tool = winmerge

[difftool "winmerge"]
    name = WinMerge
    trustExitCode = true
cmd = "/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe" -u -e $LOCAL $REMOTE''
git_cheat_sheet.1486451447.txt.gz · Last modified: 2017/02/07 20:10 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki