Git : Basic commands

Here, you will find all basics and useful commands for git :

————————————————-  Clone a project from a remote ———————————————————

$ git clone git@gva10srv3046:opt/git/projectName.git

————————————————- Local commit then commit on the remote ———————————————

git status
git add * ou git add "/file/..."
git commit -m "the comment" (commit local)

git pull (pour être à jour par rapport au serveur afin de pusher sur le trunk)

if problems (do the manual merge)

git push origin master

———————————————— Local commit then on remote of deleted files ——————————————-

git add -u
git commit -m "the comment"
git pull
git push origin master

———————————————– Reset Checkout from remote : ————————————————————

git reset --hard HEAD
git reset --hard origin/master

————————————————- Fetch all branches from remote to local: ———————————————–

git fetch origin

————————————————- Get and switch on local branch from remote: ——————————————

git checkout -b branchName origin/branchName

————————————————- File checkout: —————————————————————————–

git checkout /src/...
git checkout HEAD /src/...       <-- if a file has been deleted and note comitted

————————————————- Show history file ————————————————————————–

git blame /src/...

————————————————– Create a branch on your local machine : ———————————————-

$ git branch <name_of_your_branch>

————————————————– Push the branch on the remote server  : ———————————————-

$ git push <remote>

————————————————– Show all branches : ———————————————————————

$ git branch -a

————————————————– Push the changes on the remote branch : ——————————————–

$ git push <remote_name> <branch_name>

————————————————– Delete a branch on your local server : ————————————————-

$ git branch -D <branch_name>

————————————————– Delete a branch on the remote server : ————————————————-

$ git push <remote_name> --delete <branch_name>

————————————————– Create a bundle : ————————————————————————

$ git bundle create delivery-bundle.bundle <name_of_your_branch>

————————————————– Checkout branch from bundle : ——————————————————–

$ git remote show
$ git remote remove <remote_name_delivery>
$ git remote add <remote_name_delivery> <bundle_file.bunlde>
$ git branch -d <delivery_branch_name>
$ git fetch <remote_name_delivery>
$ git branch -b <delivery_branch_name> <remote_name_delivery>/<delivery_branch_name>
$ git push origin <delivery_branch_name>

————————————————– Merge branch : ————————————————————————–

$ git checkout <develop_branch_name>
$ git merge <branch_to_merge_in_develop>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s