Skip to content

Instantly share code, notes, and snippets.

@josdem
Last active June 4, 2023 00:10
Show Gist options
  • Save josdem/e90afa245c0aa318d85a to your computer and use it in GitHub Desktop.
Save josdem/e90afa245c0aa318d85a to your computer and use it in GitHub Desktop.
## Basic Commands
//Clone a project
git clone git@github.com:josdem/jmailer-spring-boot.git
//Get lastest changes from a project
git pull origin master
//Commit a change to a project
git commit -am "This is a comment about my changes to the project"
//Push changes to the repository
git push origin master
//Create a branch
git checkout -b ${branchName}
//Download objects and refs from another repository
git fetch
//Get the current branch name in Git
git branch
//Show your Git username and email
git config user.name
git config user.email
//Set user
git config --global user.name "josdem"
//Set user email
git config --global user.email "jose.morales@dominos.com"
git config --global user.email "joseluis.delacruz@gmail.com"
//Make Git use vim editor for commits
git config --global core.editor "vim"
## Advance commands
// Show remote repositories
git remote -v
// Removing a remote
git remote rm origin
// Show specific file in specific commit
git show <treeish>:<file>
//Delete a local branch
git branch -d ${branchName}
//Delete a remote branch
git push origin --delete ${branchName}
//Adding a remote repository
git remote add bitbuket git@bitbucket.org:josdem/cien-hundreds.git
//Listing remote branches
git ls-remote
//Count all commits in a project
git rev-list --all --count
//Count commits by user
git shortlog -s -n --all --no-merges
##Tags
//Create a tag
git tag -a tag/setup -m "Creating setup tag"
//Deleting a tag
git tag -d tag/setup
//Pushing a tag
git push origin tag/setup
//listing tags
git tag
#Merge
//Getting their changes
git checkout --theirs grails-app/views/company/_products.gsp
//Undo last commit
git reset --soft HEAD~1
//Imprimir el log colorized
git log --pretty=oneline
## Moving to a previous commit
# Resets index to former commit; replace '56e05fced' with your commit code
git reset 56e05fced
# Moves pointer back to previous HEAD
git reset --soft HEAD@{1}
git commit -m "Revert to 56e05fced"
# Updates working copy to reflect the new commit
git reset --hard
# Add executable permissions to Gradle script
git update-index --chmod=+x gradlew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment