Created
November 3, 2021 03:56
-
-
Save debu999/75033bafad54e6822cf18b74bf07e975 to your computer and use it in GitHub Desktop.
Git Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git config --global user.name "Debabrata Patnaik" | |
$ git config --global user.email "[email protected]" | |
$ git config --global alias.co commit | |
//Run the following command inside the folder | |
$ git init | |
//Run the following command to create a new directory that is a git repo | |
$ git init DIRECTORY_PATH/DIRECTORY_NAME | |
$ git clone LINK | |
$ git clone [email protected]:debu999/pluralsight_datascience.git | |
$ git clone https://github.com/debu999/pluralsight_datascience.git | |
//download the state for all the branches | |
$ git fetch | |
//fetch for just one branch | |
$ git fetch <remote> <local> | |
//<remote> is the name of the remote branch | |
//<local> is the name of the local branch | |
//an example of it is | |
$ git fetch origin main | |
$ git pull | |
$ git pull --all | |
$ git status | |
$ git add /path-to-test-py/test.py | |
$ git commit -m "JIRA#: The message you want to write to describe this commit" | |
$ git push <remote> <local> | |
//<remote> is the name of the remote branch //<local> is the name of the local branch //an example of it is | |
$ git push origin main | |
$ git log --graph --oneline --decorate | |
$ git log --oneline | |
$ git reverse | |
$ git reset --hard commit# | |
//this lists the name of the branches present | |
$ git branch | |
$ git branch -r | |
$ git branch --all | |
//delete a branch safely | |
$ git branch -d <branch> | |
$ git branch -d another_branch | |
//switch to a different branch | |
$ git checkout <branch_name> | |
$ git checkout another_branch | |
//create a new branch | |
$ git checkout -b <new_branch_name> | |
$ git checkout -b new_feature_branch | |
//print any uncommitted changes since the last commit. | |
$ git diff | |
//compare code between two branches | |
$ git diff branch1 branch2 | |
//print the uncommitted changes made in one file | |
$ git diff /filepath/filename | |
$ git pull origin main | |
$ git checkout another_branch | |
$ git rebase main | |
few aliases to ponder about | |
alias.lga=log --all --oneline --decorate --graph | |
alias.lg=log --all --color --graph --date=format:'%Y%m%d %H:%M' --pretty=tformat:'%C(magenta)<%ad>%Creset: %Cgreen%H%Creset %C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
alias.br=branch --all | |
alias.dh=diff HEAD --name-status | |
alias.lgs=log --all --color --graph --date=format:'%Y%m%d %H:%M' --pretty=tformat:'%C(magenta)<%ad>%Creset: %Cgreen%HD%Creset $s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --name-status | (awk 'ORS=NR%3? : | |
alias.po=push --origin | |
alias.publish=!git push --set-upstream origin $(git branch --show-current) | |
alias.pa=pull --all | |
alias.url=config --get remote.origin.url | |
alias.pta=push origin --tags | |
alias.pt=push origin | |
alias.dell=branch -D | |
alias.delr=push origin --delete | |
alias.rc=rebase --continue | |
alias.ft=fetch | |
alias.ftp=fetch --tags --prune | |
alias.pr=pull --rebase | |
alias.co=checkout | |
alias.wd=diff --word-diff | |
alias.so=remote show origin | |
alias.st=status | |
alias.conf=config | |
alias.sh=show | |
alias.cm=checkout main | |
alias.ci=commit -a | |
alias.ad=add | |
alias.fo=fetch origin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment