git remote -v
git remote show
git remote add
git fetch
git fetch --all
git pull | git pull
git push
git push
git push origin :old-name new-name
git push origin -u new-name
git branch -dr
git push origin YourTagVersion
Git undo
git reset --hard HEAD
git reset --soft
git checkout HEAD
git revert
git reset --hard
git reset --hard
git reset --keep
Git stash
git stash list
Git merge and rebase
git merge
git rebase
git rebase --continue
git rebase --abort
git mergetool
git add | git rm
Git local changes
git status
Changes files in your working directorygit diff
Changes to tracked filesgit diff <filename|filepath>
Show or list our the changes of specific file as per comparison to previous commitgit add . | git add ..
Add all current changes to the next commitgit add FILENAME
Add particular file changes to the next commitgit add -p
git commit
git commit -m 'Commit description'
git commit -a
git commit --amend
git commit --amend -m "an updated commit message"
git commit --amend --no-edit
Git create a repository
git init
Create a new local repository
The git init command creates a new Git repository. It can be used to convert an existing, unversioned project to a Git repository or initialize a new, empty repository. Most other Git commands are not available outside of an initialized repository, so this is usually the first command you’ll run in a new project.git clone <url>
Clone an existing repository
s a Git command line utility which is used to target an existing repository and create a clone, or copy of the target repository. In this page we’ll discuss extended configuration options and common use cases of git clone.
It can be used to:
– clone a local or remote repository
– clone a bare repository
– use shallow options to partially clone repositories
– git URL syntax and supported protocols
Git config file tips
These commands work on /.git/config filegit config --system--unset credential.helper
git config --global--unset credential.helper
git config --global credential.helper wincred
git config --global credential.helper osxkeychain
To update your credentials, go to Control Panel → Credential Manager → Generic Credentials. Find the credentials related to your Git account and edit them to use the updated password.
Reference: How to update your Git credentials on Windows
Note that to use the Windows Credential Manager for Git you need to configure the credential helper like so:
git config --global credential.helper wincred
If you have multiple GitHub accounts that you use for different repositories, then you should configure credentials to use the full repository path (rather than just the domain, which is the default):
git config --global credential.useHttpPath true
The only thing that worked for me was navigating to C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree and removing the passwd file.
Once this file is removed, restart SourceTree and execute a fetch or something else that requires access to the repo in question. SourceTree will then prompt you for your password, rewriting the cached credentials.
I hope this helps. Shoutout to my buddy Nick for the assist.
If you’re a macOS user, Auke states below that “you can find the password files per repo it in ~/Library/Application Support/SourceTree”
Git commit history
git log
git log -p
git blame
git log --online --graph --decorate
Git branches and tags
git branch
git branch -av
git checkout
git checkout -b
git checkout -b destination-BranchName sourceBranchName
How to keep a feature branch in sync with it’s parent branch
git checkout develop
git pull
git checkout feature/foo
git merge develop
git push
orgit checkout feature/foo
git pull --all
git rebase develop
Git Azure DevOps on Mac
Reference:
https://docs.microsoft.com/en-us/azure/devops/repos/git/set-up-credential-managers?view=vsts
https://github.com/Microsoft/Git-Credential-Manager-for-Mac-and-Linux/blob/master/Install.md
Update the Homebrew/Linuxbrew formulae to make sure you have the latest versions:brew update
Install the GCM4ML formula:brew install git-credential-manager
Run the GCM4ML in install mode, which will check its requirements and then update the “global” Git configuration file (the one in your home folder):git-credential-manager install
Create local repogit init
Add Azure DevOps remotegit remote add origin https://
Pull from master branchgit pull origin master
Pull from Develop branch (if it exists)git pull origin Develop