-
git init->powers your folder to manage by git and initialises a new repository . It also creates a .git folder that has all the revelant logic to manage versions of your projectInside Git there are three areas divided where our code chages occurs -
Working Area->There can be a bunch of files that are not currently bunch by git . It means changes done or can be done in those files that are not managed by git.A file that is in working area is considered to be not in the staging area. When we dogit statusand we see abunch ifumtracked filesthen these are actually called in working area; -
Staging Area->What are files are going to be part of the next version we will create . This staging area is the place where git knows that chnages will be done in the last version to the next version. -
Repository Area->This area actually contains all the details of all your previous registered version. And this file in this area ,git already manages them and knows their history. -
git add <file>->moves file from working area to staging area -
git rm --cached <file>->moves file back from staging area to working area -
commit-> commit is a particular version of the project.It captures a snapshot of the project's staged changes and creates a version of out of it. -
git commit->register staging chamges to commit -
git log->list down all the commits of the repository.if you want to exit out of git log then pressq -
git restore <file>->It removes all the files chages from the staging area to be commited .This can be useful. If we did some dirty part of the code and now no more of it then instead of deleting every change line by line ,we can restore it or you can say restore last clean version of the file -
git comit -m "<your commit message>"-> If we want to avoid opening a text editor like vim/nano to add commit message we can use the following commands -
VS code shows green bar which means all these in working area.
-
git remote->list down all the connection name -
Remote Connection->It helps you to link two git repositories for uoploading and downloading the changes
-
git remote add <name of remote> <link of remote>->this command helps to add the new link to the remote repo and give a name to it -
git remote rm <name of remote>:this commands delete the remote connection -
git add <file1> <file2> <file3>: This command will add multiple files togetheer in staging area -
git add .: this command adds all files to working area to staging area. -
git pull <remote name> <branch name>:download the latest changes form the branch of the mentioned remote in your local repo .
- make changes
- git add <files>
- git commit
- git pull
- git push
vim <file name>-> isse hum ek nayi file banate hain same as touch command but vim cmd use karne se hum terminal me hi content likh sakte haingit stash-> is command ko use karne se hamari file jo humne create ki hai wo delete ho jaegi lekin wo file tabhi delete hogi jab wo staging area me hogi means {git add } command ko use karne segit stash listgit stash apply->hamari deleted file wapas aa jaegigit stash show stash@{stash number}cat <filename>->iss command ko use karne se hamara file ke andar kya hai wo print ho jayegagit stash --include-untracked->ye command use hota hai untracked file ko delete karne ke liyegit stash drop stash@{stash number}->this make the stash@{} deletedgit stash clear->if we want to remove everything in the stash then we do this