Comandos Git
Comandos Git
git init
git clone repo_url
git clone
ssh://[email protected]/[username]/[repository-
name].git
git status
git add [file-name]
git add -A
git commit -m "[commit message]"
git rm -r [file-name.txt]
git branch
git branch -a
git branch [branch name]
git branch -d [branch name]
git branch -D [branch name]
git push origin --delete [branch name]
git checkout -b [branch name]
git checkout -b [branch name] origin/[branch
name]
git push
git init
git status
git stash
git branch
git branch -r
git rebase origin/master
git remote -v
git remote set-url origin
https://github.com/user/repo.git
git remote add [NAME]
https://github.com/user/fork-repo.git
git log
git log -p
git diff
git shortlog -s -n
Check status
Add a file to the staging area
Add all new and changed files to the staging area
Commit changes
Remove a file (or folder)
List of branches (the asterisk denotes the current
branch)
List all branches (local and remote)
Create a new branch
Delete a branch
Delete a branch forcefully
Delete a remote branch
Create a new branch and switch to it
Clone a remote branch and switch to it
View changes
View changes (detailed)
View changes (briefly)
Preview changes before merging
Revert commit changes
Set globally Username
Set globally Email id
Get global config
Stashing files
Git stash is a very useful command, where git will 'hide' the
changes on a dirty directory - but no worries you can re-apply
them later. The command will save your local changes away and
revert the working directory to match the HEAD commit.Stash
local changes
Stash local changes with a custom message
Re-apply the changes you saved in your latest stash
Re-apply the changes you saved in a given stash number
Drops any stash by its number
Apply the stash and then immediately drop it from your stack
Release' a particular stash from your list of stashes
List all stashes
Show the latest stash changes
See diff details of a given stash number
Committing files
After adding/staging a file, the next step is to commit staged
file(s).Commit staged file(s)
Add file and commit
Add file and commit staged file
Amending a commit
Squashing commits together. This will give you an interface on
your core editor:
Commands:
p, pick = use commit
r, reword = use commit, but edit the commit message
e, edit = use commit, but stop for amending
s, squash = use commit, but meld into previous commit
f, fixup = like "squash", but discard this commit's log message
x, exec = run command (the rest of the line) using shell
Squashing commits together using reset --soft. ** WARNING: this will require force pushing commits, which is OK if this is
Branching and merging. Creating a local branch
Switching between 2 branches (in fact, this would work on terminal as well to switch between 2 directories - $ cd -)
Pushing local branch to remote
Deleting a local branch - this won't let you delete a branch that hasn't been merged yet
Deleting a local branch - this WILL delete a branch even if it hasn't
been merged yet!
Remove any remote refs you have locally that have been removed from your remote (you can substitute <origin> to any re
Viewing all branches, including local and remote branches
Viewing all branches that have been merged into your current branch, including local and remote
Viewing all branches that haven't been merged into your current
branch, including local and remote
Viewing local branches
Viewing remote branches
Rebase master branch into local branch
With the remote branches in hand, you now need to check out
the branch you are interested in, giving you a local working copy:
Resetting
Mixes your head with a give sha
This lets you do things like split a commit
Upstream master
The version from the most recent commit
The version before the most recent commit
Move head to specific commit
Reset the staging area and the working directory to match the
most recent commit. In addition to unstaging changes, the --hard
flag tells Git to overwrite all changes in the working directory, too.
Git remote
Show where 'origin' is pointing to and also tracked branches
Show where 'origin' is pointing to
Git blame
Show alteration history of a file with the name of the author
Show alteration history of a file with the name of the author &&
SHA
List of commits with the particular expression you are looking for
List of commits by author
Shows the log in a more consisted way with the graph for
branching and merging
alias
- or in other words, stage file(s).Adding a file
n removed from your remote (you can substitute <origin> to any remote branch)
mote branch)