My Self Post : Git Commands
..................................................................................
git config : email and name set by this
git config user.name - set name of the user
git config user.email - set email of the user
git init : a new repository start
git init -y : create a package.json file
git clone: project setup
git add <filename> : add the file to git
git add. : add all the files
mkdir <name> : make the folder or directory in the linux board
git diff <filename> : see the full file with changes
git reset: Do reset ,Do Unstages and Do preserve the contents
git commit: what will push that commit will make :: git commit -m"commit_name"
git status: what happened in project :: see
git rm: rm file name or git rm -f filename
this command delete this file from the working directory
git log: what happen at the branches in the project
git branch: at which branch we are working
git checkout branch: go to another branch
git checkout -b branch : create and go to another branch
Note: Current Branch is with * Branch
git Remote: It tells which remote is working now | Remote I think which is woring as github or origin
git help: all the git commands
git remote add origin : do add the origin of git at remote {your account}
git pull origin master : take pull
git push origin master: give push
git show: this command show the metadata and content changes.
.................................................................................................................................................................
Some Very Important git Commands
heroku login : login heroku at the server
heroku create: create heroku before pussing
git pull heroku master
git push heroku master
.................................................................................................................................................................
.................................................................................................................................................................
Some Heroku Commands
heroku login : login heroku at the server
heroku create: create heroku before pussing
git pull heroku master
git push heroku master
.................................................................................................................................................................
git fetch
git fetch is the command to downloads the commit files and refs into your local repository through your remote repository
fetching:
A safe way to review commits before integrating them with your local repository.
.................................................................................................................................................................
delete the branch in git
git branch -d <branchname>
.................................................................................................................................................................
delete the remote branches
To delete a remote branch, you can’t use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name (origin in this case) after git push.
git branch -a
# *master
# test
# remote/origin/master
# remote/origin/test
git push origin --delete test
# To <URL of your repository>.git
# - [deleted] test
.................................................................................................................................................................
git log
git log --oneline
.................................................................................................................................................................
git conflicts
अगर दो branches में दो files में content बिलकुल different है और उन दो branches को merge किया जाता है then conflicts will come.
agar conflicts ate hain toh ek bar conflicts ko resolve karne ke baad dubara merge nai karna hai humein.mege toh ho gaya sirf add karke aur commit banakar code ko push karna hai humein
.................................................................................................................................................................
git stashing
git stashes ek temporary storage hoti hai
ki agar meine apna adhe se jyada code likh liya hai aur koi aur naya kaam aa gaya hai mere paas ki yeh kaam jaldi se kar do bad mein tum apna kam dubara kar lena toh hum humare likhe gaye code ko stash mein bhej dete hain usse humari working directory khali ho jaati hai toh hum us bande ke code par kam karke use de dete hain fir hum apne code ko wapas late hain aur use bhi save kar lete hain
stash mein bhej dene ke bad meine us bande ka kam karna start kar diya aur fir maine jo kam mein pehle kar raha tha usko start kar diya us bande ka kam karne ke bad mein add karke aur commit kar dunga commit karne ke bad meri working directory fir se khali ho jayegi ab mein is file ko dubara wapas launga aur stash store mein se aur jo fir new file mein mein kam karung usko mein add karunga apne staging are mein aur fir mein usko commit kar dunga toh maine apne purane kam ko rokkar naya kam start kar diya aur fir mein apna purana kam kar diya is tarah se stash store ki wajah se dono hi kaam ho gaye
stash ke tarika hai jismein aap apni hi branch mein rehkar apne hi kaam ko thodi der ke liye side mein rakh dete hain aur dusre bande ka kam karne add and commit karke jab working directory khali ho jati hai toh fir dubara se is kam ko kar dete hain.
stash apply only to modified files not to the new files
command:
git stash - any file will go to stash storage
git stash list
git stash apply stash@{0} - this file will come to the working directory
or
git stash apply stash@{1}
or
git stash apply stash@{2}
stashlist mein numbering hoti hai woh kam ati hai stash file ko dhundhne mein aur fir us par work karne mein
Very Imp note:
Whenever we will get data by stash then it will be live in the stash also.
git stash clear :
By this command stash storage will be cleared.
.................................................................................................................................................................
git reset
command: git reset.
this command is used to reset all the things in reset.
Command: git reset --hard ::::::::::::::::::::: It will remove by the working stage and the staging area.
......................................................................................................................................................................
.........................Very Important Note.........................
......................................................................................................................................................................
git reset : before commit
git revert : after commit
......................................................................................................................................................................
.......................................................................................................................................................................
....................... git Revert....................
git revert command helps you to undo an existing command
Note: Revert public file par kiya jata hai
Note: Reset Private file par kiya jata hai
Commit ko wapas nai la sakte
commit ko delete nai kar sakte
commit ko revert kar dete hain commit id se
revert command se previous commit ko hum age le ate hain
Revert Command
It does not delete any data
git revert generate a new commit id
......................................................................................................................................................................
.......................................................................................................................................................................
....................... git Tags...................
......................................................................................................................................................................
......................................................................................................................................................................
Apply Tag to a particular commit:
git tag -a <tagname> -m <message> <commit id>
Watch the List of Tags:
git tag
To delete a tag:
git tag -d <tagname>
......................................................................................................................................................................
.......................................................................................................................................................................
....................... git Cloning...................
......................................................................................................................................................................
......................................................................................................................................................................
Comments
Post a Comment