0% found this document useful (0 votes)
15 views1 page

GIT Commands

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

GIT Commands

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Git commands:

1) git init - to initialize a local git repository


2) git status - to see if all the files have to moved to the STAGING AREA (i.e. has
the status of all the files being updated in the git)Note: The staging area is a
place where all the files to be commited (saved) are brought
3) git add file_names - to move the specified file to the staging area ['git add .'
is used to move all the files to the staging area]
4) git commit -m "message" - to save the files with some description
5) git log - gives you information regarding all the commits that you have made
[Info : Date and time of commit, message of commit, who made the commit, the hash
of the commit - this is something (an ID, say) that will uniquely identify a
particular commit]
HEAD->master - current state that we are in
6) git diff file_name - to tell the difference between the last commit and the
present file (uncommited file)
7) git checkout file_name - to rollback to the previous version of the file
8) git remote add name link_to_the_remote_repository - to create a remote
repository
9) git push name branch-name : to push the local repo files to the remote repo
10) git clone link_of_the_repository : to clone the repo from github into our local
machine
11) git branch - this will give you the list of all the branches (and master
branch)
12) git branch branch_name : to create a new branch
13) git checkout branch_name : to switch between various branches
14) git merge branch_name : to merge two brnaches
Note: you need to write this command by switching into that branch where you want
to merge into. So, you mention the branch to be merged in the command
15) git rm --cached file_names : to remove the files from the staging area.
15) git revert --hard commit_hash : to revert to any of the previous specific
commits (Note: applicable to only git not github i.e., you can go to the )

Note:
What is git remote add ...?

As you probably know, Git is a distributed version control system. Most operations
are done locally. To communicate with the outside world, Git uses what are called
"remotes". These are repositories other than the one on your local disk which you
can push your changes into (so that other people can see them) or pull from (so
that you can get others changes). The command git remote add origin
[email protected]:peter/first_app.git creates a new remote called origin located at
[email protected]:peter/first_app.git. Once you do this, in your push commands, you
can push to origin instead of typing out the whole URL.

What is git push origin master?

This is a command that says "push the commits in the local branch named master to
the remote named origin". Once this is executed, all the stuff that you last
synchronised with origin will be sent to the remote repository and other people
will be able to see them there.

You might also like