Git Commands

Git is useful command in writing program and we want to preserve the working earlier codes while testing a new change.

And these are the command I learnt.

git init master // for registering the working directory to git
git add . // add all files inside to git monitor but only in current tree
git add -A subtree/ // all all files include subtree
git commit -m "write what i had change" //put all change to the active branch
git config --global "firstname lastname" //define the git to github
git config --global "user@email.gom" //define the git to github account
git config --global user.password "thepass"  //defint the git to github account
git remote add origin httsp:// //this one too
git push -u origin master //upload all the file in tree to github
git pull -u origin master //download the copy in github account to local
git status //check the status git, usually display the file change
git checkout newbranchname //create new branch based on the working tree
git diff serial1 serial2 //check the different between two file changed
git restore * //revert the change to the beginning or simply change the * to certain file
git checkout -b newbranch // create new branch name newbranch
git branch // list branch and the our position in the current branch
git branch -d branchtodelete // delete the branch
git status // see the file status in current branch
git reset --hard //undo all change at once
git restore namefile //undo change to certain file
git merge new-branch //merging all from new-branch to master (remember to position to the master-see checkout

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.