Set git user
Add and remove submodules
Get all submodules of a repo
Remove a submodule from a repo source
To remove a submodule you need to:
- Delete the relevant line from the
- Delete the relevant section from
git rm --cached path_to_submodule(no trailing slash).
- Commit and delete the now untracked submodule files.
Create remote branch
Configure git with
push.default = current to make life easier:
-u will track remote branch of same name. No with this configuration you will auto-guess the remote reference to git push. From git.config documentation:
Defines the action git push should take if no refspec is explicitly given.
push.default = current- push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.
Rename local branch
If you want to rename a branch while pointed to any branch, do:
If you want to rename the current branch, you can do:
Rename remote branch
If you want to rename (or move) a remote branch, type:
Remember to reset the upstream branch to the new name, switch to the branch and type:
Delete local branch
To delete a local branch type:
Delete remote branch
Type the following to delete a remote branch:
Check diff between local and remote branches
- go to your repo and do
git diff <local_branch_name> <remote_branch_name>
- check your file changes
Some options to try in step 2 are:
git diff --sumary FETCH_HEAD- gives an overview of the changes.
git diff --stat FETCH_HEAD- gives more information than
git diff FETCH_HEAD -- <some_dir/some_file>- show information only for a selected file.
Cloning a repo with HTTPS
cloning public repo
$ git clone https://github.com/atmantree/exercism.git
cloning using user and password (avoid this)
Create an orphan branch
Use of git stash
git stash to save the current state of the working directory of the repo, while we checkout another branch without commiting.
The command to get back the changes we made is
git stash pop.