Most Common Git Commands

git branch -b new_feature
git branch –no-merged # show the branches that are not merged yet.
git merge –no-ff new-feature -m “merge new-feature branch”
git branch -D new-feature # delete the working branch after merge is completed

 

Working with GitHub

create a GitHub repo hello-remote

git clone <URL for hello-remote>
git clone https://github.com/hydrogeologist/hello-remote.git
git status

add a demo file in local clone, demo.txt

git add demo.txt
git commit -m “added a demo file”

git push -u origin master # now upload the file to the GitHub.

git fetch origin # use this to update the local clone of the remote repository. This let us know how many commits have been made since the last pull
git remote -v # shows the branch on the remote location.

git pull # use this command to update the local repo. (Behind the scenes, git pull is actually a git fetch followed by a git merge)

Coll flag for git diff:

git diff –color-words

Try this feature.
git branch –merged : shows all of the branches that are merged.

Take a look at the diff between branches:
git diff master..branch_name

Rename a branch in Git
git branch -m old_branch_name new_branch_name
git branch –move old_branch_name new_branch_name

Delete Branches
git branch -d branch_name
git branch –delete branch_name

if there are changes in the branch that is not merged yet, we must use D
git branch -D branch_name # forced delete

 802 total views,  1 views today

about author

Ankan Basu

ankanbasu@ankanbasu.com

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.