Useful Git commands
Git command |
What it does |
---|---|
|
Checkout a branch that already exists (local or remote) |
|
Create and checkout a branch locally |
|
Checkout the master branch |
|
Clone a repo from url to a directory |
|
Update and pull from origin |
|
Get the latest copy of the repo |
|
Get the latest master from the origin |
|
Revert file-name to the version in the repo |
|
Updates all of your local branches that are set to track remote ones, does not merge any commits. |
- |
- |
|
List all branches locally and origin |
|
Delete a branch |
|
Remove listings of deleted remote branches. Delete remote branches will still appear when you do git branch -a unless you use this command before. |
|
Shows what deleted remote branches would be removed by using git remote prune origin. Only shows what would be removed, does remove anything. |
- |
- |
|
Add a file to the staging area for committing |
|
Add all files of type to the staging area for committing |
|
Add all modified files to the staging area for committing |
- |
- |
|
Move a file to a new folder |
- |
- |
|
Commit the staged area with a descriptive message |
|
Asks Jenkins to retest a pull request. |
- |
- |
|
Merge the changes from [branch] to the one you have currently checked out, typically master to your dev branch |
|
Update all submodules and merge them |
|
Update the submodule references on the remote system to the current commits |
|
Update your local submodules to those referenced on the remote system |
|
USE ONLY ON LOCAL BRANCHES - reapply your changes to the most recently pulled master |
|
‘clear out’ any submodules with new commits |
|
status of the submodule(s) at this moment, e.g. what the current checkout commit of the submodule is |
|
status of the submodule(s) as they appear in the index, e.g. the expected commit associated with EPICS working copy |
- |
- |
|
Push a new branch to the origin |
|
Push a branch to the origin |
- |
- |
|
Get the status information |
|
Get a summarised status, note that M means Modified, ?? Mean untracked |
- |
- |
|
Remove unstaged files |
|
Remove unstaged files and directories |
- |
- |
|
Get the remote URL of a repository |
- |
- |
|
Put all current modifications onto a stack |
|
Apply the changes from the last stash |
|
Drop the most recent stash from the stack |
|
Apply and drop the most recent stash from the stack |
|
Creates a new branch from the commit when the branch was stashed, applies the stash, and if successful drops the stash |
|
Delete all stashes |
- |
- |
|
Remove a file from the staging area |
- |
- |
|
View the commit history |
|
Limit the number of entries shown by the log |
|
Show the diffs as well as the log |
|
Abbreviated stats for each commit |
- |
- |
|
Allows you to amend you last commit (missing files, or alter message) |
- |
- |
|
Unstage a file |
|
Reset the branch to a specific checkout |
|
Reverse the commit to the previous one |
|
unstage all files |
- |
- |
|
Get the commit info for the most recent commit |
- |
- |
`git config -l –global |
grep http` |
`git config -l |
grep http` |
|
Remove http proxies from global config |
|
Remove https proxies from global config |
|
Remove http proxies from local config |
|
Remove https proxies from local config |
Set local branch to be the same as remote
To set the local master branch to be the same as remote do:
git fetch origin
git reset --hard origin/master
This can be in response to the error:
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: At least 1 approving review is required by reviewers with write access.