Categories
Git Linux Server PHP

Basic Git commands and use of these commands

If you are looking for the git commands like git push, git stash, git add, git merge, git reset, git branch, git checkout, git pull origin, git status, git log and more then this post is the best resource of knowledge for you.

Once you have installed git on your local computer then you have to go to the folder where git is installed.
To go to the folder you can write the following
pwd
cd c:/xampp/htdocs/
git branch

If you are using Git Public Repository then you must be aware about the following basic commands of Git.
Here is a small list of basic Git commands.

git push origin :BN – remove/delete branch from git server/repository

git stash – if there are conflicts and you want to avoid those conflicts

(git add filename) in which u resolved conflict then (git commit -a -m “resolved conflict while making design changes by nilesh”) then git push origin Dev and see your changes

git merge commit_id (to commit the changes in the branch that you are in now)

git reset – -hard (Reset current HEAD to the specified state)

git reset – -hard origin/master (if you are in master branch and git pull showing some conflicts then you can use this command to reset the master)

git branch -D BN – to delete a branch (you must be in other branch(i.e master or IndexFlowVaseem) to delete this branch)

git fetch origin BN:BN – to pull branch data from git

pwd – to see current working directory

git branch MyNewBranch – to create a new branch

git checkout master – to work in master branch or to switch master branch

git pull origin branchname – to get the github.com data on your local computer or git pull origin Dev

git pull origin Dev – a new branch named as Dev will be created with the code from git

git status – to see the changes in your branch and in github.com branch

git commit filepath_name1 filepath_name2 -m “your comment” – to commit the changes you have made

git push origin MyBranch – to upload your data to git branch

git add filename1 filename2 – to add new files in git

git log – to see the commit in the current branch

rm filename1 filename2 – to delete files

The most commonly used git commands are:
add–Add file contents to the index
bisect–Find by binary search the change that introduced a bug
branch–List, create, or delete branches
checkout–Checkout a branch or paths to the working tree
clone–Clone a repository into a new directory
commit–Record changes to the repository
diff–Show changes between commits, commit and working tree, etc
grep–Print lines matching a pattern
init–Create an empty git repository or reinitialize an existing one
log–Show commit logs
merge–Join two or more development histories together
mv–Move or rename a file, a directory, or a symlink
pull–Fetch from and merge with another repository or a local branch
push–Update remote refs along with associated objects
rebase–Forward-port local commits to the updated upstream head
rm–Remove files from the working tree and from the index
show–Show various types of objects
tag–Create, list, delete or verify a tag object signed with GPG

By Vaseem Ansari

Hey guys this is Vaseem Ansari, 27 years old, Software & Web Developer, Blogger & works on Wordpress Plugin Themes Development, PHP MySql Programming and Open Sources Technologies.
It takes a while for me to build trust in someone new. I am honest, thoughtful. I'm Glad I'm Me No one looks The way I do. No one walks the way I walk. No one talks the way I talk. I am me. There's no one else I'd rather be! Have fun reading this blog and don't forget to subscribe to the feed to keep updated on the latest articles.

3 replies on “Basic Git commands and use of these commands”

Leave a Reply

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