Sharing and Updating Projects

git-fetch

Download objects and refs from another repository

git fetch [<options>] [<repository> [<refspec>ā€¦ā€‹]]
git fetch [<options>] <group>
git fetch --multiple [<options>] [(<repository> | <group>)ā€¦ā€‹]
git fetch --all [<options>]

git-pull

Fetch from and integrate with another repository or a local branch

git pull [<options>] [<repository> [<refspec>ā€¦ā€‹]]

git-push

Update remote refs along with associated objects

git push [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
	   [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-q | --quiet] [-v | --verbose]
	   [-u | --set-upstream] [-o <string> | --push-option=<string>]
	   [--[no-]signed|--signed=(true|false|if-asked)]
	   [--force-with-lease[=<refname>[:<expect>]] [--force-if-includes]]
	   [--no-verify] [<repository> [<refspec>ā€¦ā€‹]]
Snippets
  • this will push all the code to the remote repository i.e. Github (Code Hosting Provider) to track changes in the project.

git push -u origin master
  • when we want to publish our local branch on a remote repository,

git push -u origin <local_branch_name>
  • to delete a remote branch,

git push origin --delete <branch_name>

git-remote

Manage set of tracked repositories

git remote [-v | --verbose]
git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=(fetch|push)] <name> <URL>
git remote rename [--[no-]progress] <old> <new>
git remote remove <name>
git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
git remote set-branches [--add] <name> <branch>ā€¦ā€‹
git remote get-url [--push] [--all] <name>
git remote set-url [--push] <name> <newurl> [<oldurl>]
git remote set-url --add [--push] <name> <newurl>
git remote set-url --delete [--push] <name> <URL>
git remote [-v | --verbose] show [-n] <name>ā€¦ā€‹
git remote prune [-n | --dry-run] <name>ā€¦ā€‹
git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)ā€¦ā€‹]
Snippets
  • displays information about remote repositories associated with the local repository

git remote -v
  • this command will link the remote repository to the local repository.

git remote add origin <url>

git-submodule

Initialize, update or inspect submodules

git submodule [--quiet] [--cached]
git submodule [--quiet] add [<options>] [--] <repository> [<path>]
git submodule [--quiet] status [--cached] [--recursive] [--] [<path>ā€¦ā€‹]
git submodule [--quiet] init [--] [<path>ā€¦ā€‹]
git submodule [--quiet] deinit [-f|--force] (--all|[--] <path>ā€¦ā€‹)
git submodule [--quiet] update [<options>] [--] [<path>ā€¦ā€‹]
git submodule [--quiet] set-branch [<options>] [--] <path>
git submodule [--quiet] set-url [--] <path> <newurl>
git submodule [--quiet] summary [<options>] [--] [<path>ā€¦ā€‹]
git submodule [--quiet] foreach [--recursive] <command>
git submodule [--quiet] sync [--recursive] [--] [<path>ā€¦ā€‹]
git submodule [--quiet] absorbgitdirs [--] [<path>ā€¦ā€‹]

Last updated