Last active
August 21, 2022 09:13
-
-
Save dtelaroli/a17f3d90cd91888380e2d8d51fc00209 to your computer and use it in GitHub Desktop.
Git essentials commands
This file contains hidden or 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
# Configuration | |
git config user.name "My Name" | |
git config user.email "[email protected]" | |
# Initialize a git repository | |
git init | |
# Add all files to be commited | |
git add . | |
# Add one file to be commited | |
git add -- name_of_file.ext | |
# Add all files inside one folder to be commited | |
git add -- name_of_folder | |
# Commit | |
git commit -m 'Commit description' | |
# Update local repository from a remote (origin = remote name, master = branch name) | |
git pull origin master | |
# Send commit to a remote repository | |
git push origin master | |
# Clone a remote repository | |
git clone git@host:user/repository.git | |
ex: git clone [email protected]:dtelaroli/docker-rails.git | |
# Show origin details (origin = remote name) | |
git remote show origin | |
# Create a branch | |
git checkout branch_to_be_copied | |
git checkout -b branch_name | |
# Merge branches | |
git checkout branch_to_receive_merge | |
git merge branch_to_be_merged | |
# Undo all changes | |
git checkout . | |
# Undo changes in specific file | |
git checkout -- file_name.ext | |
# Undo commit definetelly | |
git reset --hard hash_to_commit_or_branch | |
# Finding the guilty | |
git blame filename.ext | |
# Checking steps | |
git reflog | |
# Checking commits | |
git log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment