It moves a file (or folder) to another folder or directory
git mv -v [source] [destination]
(-v or --verbose) Report the names of files as they are moved.
git mv -n [source] [destination]
(-n or --dry-run)Do nothing; only show what would happen
git mv -f [source] [destination]
(-f or --force)Force renaming or moving of a file even if the target exists
git mv -k [source] [destination]
(-k) Skip move or rename actions which would lead to an error condition. An error happens when a source is neither existing nor controlled by Git, or when it would overwrite an existing file unless [-f] is given.
git add [file]
Add a file to the staging area
git add -A
Add all new and changed files to the staging area
git commit -m "[commit message]"
Commit changes
git rm -r [file]
Remove a file (or folder)
git reset
Reset removes all the file currently present in staging area
git reset --hard
Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.
git reset --soft
Does not touch the index file or the working tree at all (but resets the head to , just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it.
git reset --mixed
Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.If -N is specified, removed paths are marked as intent-to-add
git reset --keep
Resets index entries and updates files in the working tree that are different between and HEAD. If a file that is different between and HEAD has local changes, reset is aborted.
git reset --merge
Resets the index and updates the files in the working tree that are different between and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between and the index has unstaged changes, reset is aborted.In other words, --merge does something like a git read-tree -u -m , but carries forward unmerged index entries.
This will add it in congig that in future all the contents of the .gitignore file should nevevr be staged
echo -e 'file.extension' >> ~/.gitignore
This will add file.extension in global .gitignore
echo \path\file.extension >> ~/.gitignore
This will add \path\file.extension in .gitignore
You can commit it now without any problems
Patching
Command
Description
git rebase
Reapply commits on top of another base tip
git rebase --onto <newbase>
Starting point at which to create the new commits. If the --onto option is not specified, the starting point is . May be any valid commit, and not just an existing branch name.As a special case, you may use "A...B" as a shortcut for the merge base of A and B if there is exactly one merge base. You can leave out at most one of A and B, in which case it defaults to HEAD.
git rebase <upstream>
Upstream branch to compare against. May be any valid commit, not just an existing branch name. Defaults to the configured upstream for the current branch
git rebase <branch_name>
Working branch; defaults to HEAD.
git rebase --continue
Restart the rebasing process after having resolved a merge conflict.
git rebase --abort
Abort the rebase operation and reset HEAD to the original branch. If was provided when the rebase operation was started, then HEAD will be reset to . Otherwise HEAD will be reset to where it was when the rebase operation was started.
git rebase --quit
Abort the rebase operation but HEAD is not reset back to the original branch. The index and working tree are also left unchanged as a result.
git rebase --keep-empty
Keep the commits that do not change anything from its parents in the result
git rebase --skip
Restart the rebasing process by skipping the current patch.