Git
Git commands
git --version
Version de gitgit config --global core.autocrlf true
To avoid uploading the Carriage Return character, true for windows and input for mac/linuxgit remote -v
View existing remotes reposgit remote add origin <url>
Set a remote url origingit add <files or '.'>
Add new files to be tracked by git or add changes to staging areagit commit -m '<message>'
Commited the existing changes in the staging areagit commit -am '<message>'
Add changes to tracked files and then commited them at the same timegit rm <file>
Delete tracked files in local and recorded in staging areagit rm --force <file>
Delete tracked files in local and hard diskrm <file>
Delete untracked filesgit restore --staged <file>
Remove files to unstagegit restore <file>
To discard changes in working directorygit reset HEAD <file>
Remove files from staging area . (dot)git checkout <file>
Remove files from staging area or . (dot)git stash
takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy, Adding the-u
option (or--include-untracked
) tells git stash to also stash your untracked filesgit stash save "<message>"
To provide a bit moqre contextgit stash list
To view your commits to the git stash historygit stash
takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copygit stash pop
will re-apply the most recently created stash: stash@{0}, you can choose which stash to re-apply by passing its identifier as the last argumentgit stash pop stash@{2}
git stash clear
Delete all of your stashes,git stash drop stash@{1}
delete a particular stashgit blame
Dqisplay of author metadata attached to specific committed lines in a filegit commit --amend --no-edit
Edit the last commit with prompt, (use esc+shift+z+z to save)git commit --amend --no-edit
Edit the last commit, useful when you forget to stage a file or to format your commit message the wrong way.git log --all --decorate --oneline --graph
Shows all commits and graphgit config --global alias.[name] '<command>'
Create alias for a list of commands
Undoing Commits & Changes
git checkout
Command to visit any commit or change the branch, also works by file (You can get a file from old commit to the present, then add and coomit again)git checkout -b <name branch>
This will create a new branch from any branch or commit where the HEAD is named and switch to that stategit reset --soft [SHA 1]
: Remove changes to staging area, last commit HEAD~1git reset --mixed [SHA 1]
: Remove changes to working areagit reset --hard [SHA 1]
: Reset changes to commit of [SHA-1], (needs --force when pushed the branch), also used for unmerge changesgit reset --hard HEAD~1 git pull origin <branch>
git revert [SHA 1]
Useful to undo commits in a public branch, use--no-edit
for avoid many messages
Reset Branch al repositorio remoto
Git merge
Merge without commit
Last updated