gitk |
Opens a new window to view the branches with a graphical
interface
|
git add file
|
Start tracking the file, adding it to the stage. It
is done before the commit
|
git add . |
Start tracking all the files in the current directory, adding
it to the stage
|
git blame file
|
Show who has changed lines in a file
|
git blame -c file
|
See who has changed the lines of the file indentedly
|
git blame file -l line,line
|
See who modified the file lines.
|
git branch |
Review the existing branches and the current one.
|
git branch branch
|
Create branch
|
git branch -a |
See all branches. |
git branch -D branch
|
Delete branch
|
git branch -r |
View remote branches.
|
git branch branch -c
|
Copy the branch
|
git checkout hash file
|
See the file on the hash version.
|
git checkout master file
|
See the file in the master version.
|
git checkout branch
|
Change current branch.
|
git checkout -b new branch
|
Copy the current branch to a new branch.
|
git cherry-pick hash
|
Applies a commit from a hash.
|
git clean --dry -run |
Simulate what is going to be deleted, without deleting.
|
git clean -f |
Delete the files, except the folders and gitignore.
|
git clone URL
|
Clone the remote repository.
|
git commit -m "message"
|
Register changes to the repository, along with a
message.
|
git commit -am message
|
Automatically stage the modified and deleted files and
register changes to the repository, along with a command line
message. Note:new files are not
affected.
|
git commit --amend |
Modify the most recent commit and open a text editor
to change the message.
|
git commit --amend -m "message"
|
Modify the most recent commit and change the
message from the command line.
|
git commit --amend --no-edit |
Modify the most recent commit without changing the
commit message.
|
git config |
View the list of git configurations.
|
git config --global user.name name
|
Change the your name settings.
|
git config --global user.email email
|
Change the your email settings.
|
git config --global init.defaultBranch name
|
Change the main branch.
|
git config --global alias.abbreviation
command
|
Create an abbreviation for a command.
|
git diff |
See current differences.
|
git diff hash hash
|
See differences between versions.
|
git fetch |
Downloads commits, files, and references from a remote
repository into your local repo but doesn’t merge the changes
|
git grep word
|
Shows how many times a word appears and where.
|
git grep -n word
|
Shows the line in which the word appears.
|
git grep -c word
|
Shows the number of occurrences of the word in each file.
|
git init |
Prepare the directory for git.
|
git log |
View change history.
|
git log file
|
View the change history of a file.
|
git log file --stat
|
View specific changes to files.
|
git log --all |
View all change history.
|
git log --all --graph |
View all change history graphed with branches.
|
git log --all --graph --decorate --oneline |
View the entire change history graphed with branches on a
single line.
|
git merge branch
|
Merge the changes from the mentioned branch to the current
one.
|
git pull remote-branch local-branch
|
Bring the remote repository and merge it with local branch.
|
git pull origin main |
Bring the remote repository and merge it with local branch.
|
git pull origin main --allow-unrelated-histories
|
Bring the remote repository even if there are unrelated
stories (leftover files).
|
git push remote-branch local-branch
|
|
git push origin main |
Send the changes to the remote repository.
|
git push origin --tags
|
Send the tags to the remote repository.
|
git push origin :refs/tags/name
|
Delete tags |
git rebase branch
|
Change the base of your branch from one commit to
another making it appear as if you'd created your
branch from a different commit.
|
git reflog |
List EVERYTHING, even what was deleted.
|
git remote add name URL
|
Link a remote repository.
|
git remote |
Enlazar un repositorio remoto.
|
git remote -v |
Review remote repositories being more verbose.
|
git reset hash --hard
|
EVERYTHING goes back to a previous version.
|
git reset hash --soft
|
The working directory returns to the previous version but the
staging remains intact.
|
git restore file
|
Restores the file to the previous version.
|
git rm file
|
Delete individual files or a set of them.
|
git rm --cached file
|
Delete the files from the stage.
|
git shortlog |
Show each person commits.
|
git shortlog -sn |
Only shows the people who have made commits and how many they
have made.
|
git shortlog -sn -all |
Shows all commits, even deleted ones.
|
git shortlog -sn -all --no-merges |
Shows all commits without taking into account merges.
|
git stash |
Save temporary changes not ready for a commit, leaving
everything as it was in the last commit.
|
git stash list |
View what is saved in a stash.
|
git stash pop |
Go back to the changes saved in the stash.
|
git stash new-branch
|
Move the stash modifications to a new branch.
|
git stash drop |
Delete changes from stash.
|
git status |
View project status.
|
git show |
Show the last change.
|
git show file
|
Show the file changes.
|
git show-ref --tags
|
Show hashes next to tags.
|
git show-branch |
Show branches and their commits.
|
git show-branch -all |
Show both remote-tracking branches and local branches.
|
git tag |
Show existing tags.
|
git tag -a v0.1 -m message hash
|
Create a new label.
|
git tag -d name
|
Delete tag. |