Git commands

%3CmxGraphModel%3E

Configure git

-------------

git config  --global user.name  “your username”

git config  --global user.email  “your email”



Check config

------------

git config user.name

git config user.email




Create git local repo

-------------------

Folder is already created:

git init

Folder is not created yet:

git init folder-name




check status of folder

---------------------

git status



Asking Git to track files(Staging env)

-----------------------------------

git add file-name(single file)

git add . (all files)



To remove from Staging env

---------------------------

git rm --cached file-name



Save version to git

-------------------

git add .

git commit -m 'message'



View commits

------------

git log

git log --oneline



Switch between commits

----------------------

git checkout hash-id



To get lost commits

-------------------

git reflog

git cherry-pick hash-of-previous commit





Branches

--------

To check branches:

git branch


To create a new branch:

git branch branch-name


To switch to other branch:

git checkout branch-name


To delete a branch:

git branch -d branch-name



Merge branches

---------------

git merge branch-name



Remove branches

————————————

git branch -d branch-name

Comments

Popular posts from this blog