Git - keshavbaweja-git/guides GitHub Wiki
Description | Command |
---|---|
Clone a repo | git clone <repo_url> |
Display HEAD commit id |
git rev-parse HEAD git rev-parse --short HEAD
|
Show remote url |
git remote show origin git config --get remote.origin.url
|
Set remote | git remote add origin <remote_url> |
Description | Command |
---|---|
List all branches | git branch --all |
List branch with upstream branch | git branch -vv |
Set upstream branch | git branch --set-upstream-to origin/<remote_branch_name> |
Checkout remote branch | git checkout -b <remote_branch_name> |
Delete a local branch | git branch -d <local_branch_name> |
Delete a remote branch | git push origin --delete <remote_branch_name> |
List merged branches | git branch --merged |
List not merged branches | git branch --no-merged |
Merge a branch without automated commit generated by git |
git merge <branch_name> --no-commit --no-ff |
Merge a branch as a single commit | git merge --squash <feature-branch> |
Find commits on a branch not on develop | git log develop..<branch> |
Delete stale remote refs | git remote prune <remote> |
Clean up local repo | git gc --prune=now |
Delete local branch not on remote | git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D |
Description | Command |
---|---|
Revert changes made to working copy(not yet staged) | git checkout . |
Remove untracked files and directories | git clean -fd |
Hard reset local repo |
git fetch origin git reset --hard origin/master
|
Description | Command |
---|---|
Create a tag | git tag -a <tag_name> -m "comment" |
Push all tags | git push origin --tags |
Push a specific tags | git push origin <tag_name> |
Description | Command |
---|---|
List files in a commit | git diff-tree --no-commit-id --name-only -r <commit_id> |
View changes in staged area | git diff --staged |
View changes in a commit id | git diff <commit-id>~ <commit-id> |
View changes in a commit id | git show <commit-id> |
View unpushed commits | git log origin/master..HEAD |
Diff of unpushed commits | git diff origin/master..HEAD |
Commit logs of a file | git log --follow -p -- path-to-file |
-- rename local branch, execute on the local branch to be renamed
git branch -m new-name
-- delete old remote branch and push new local branch
git branch -m old-name new-name
-- Reset the upstream remote branch for new local branch
git push origin -u new-name
git config --global http.proxy <proxy-host>:<proxy-port>