Here is all the commands of git. With the commands you can work with git very easily.
To initialize git in local working directory / folder in your computer. The command is-
git init
To get folder from github to local folder . The command is-
git clone https://github.com/your-repositiory.git
To see the changes of files in local repository , the command is-
git status
To add the changes of files in stage, the command is-
git add --all
git add -A
You can use any of the above two commands. Or if you want to add the changes of files of current directory you can use below command-
git add .
To get back from staged files to working directory, the command is-
git reset
To add files in stage only with the files which is not deleted, the command is-
git add *
To add a particular file in stage, the command is-
git add filename.filextension
To add all the files of same extension in stage, the command is-
git add *.fileextension
To commit changes of files in local repository, the command is-
git commit -m "change summary"
To get back all the last commit files to local directory, the command is-
git reset ~Head
To rollback with deleted files , git command is-
git reset --hard
To delete a specific file from directory and add it to stage, the command is-
git rm filename.fileextension
To forcefully delete changed file, the command is-
git rm filename.fileextension -f
To delete changed file in stage but not in working directory, the command is-
git rm --chached
To see the list of all branches, the command is-
git branch
To create new branch and copy the files from main to new branch, the command is-
git branch branch_name
To switch from one branch to another branch, the command is-
git checkout branch_name
To merge one branch with another branch, the command is
git checkout branch_name_you_want_to_merge
git merge branch_name_you_want_to_merge_with -m "merge message"
To push all the files to main branch in github, the command is-
git push origin main
To create a branch in github and push all the files in that branch or to push in already created branch in github, the command is-
git push origin branch_name
Fetch is to get all the changes from github to local repository. To fetch files from github to local repository the command is-
git fetch
To merge fetched files in local repository with files in working directory, the command is-
git merge
To pull files from github to local directory (pull = fetch + merge) . The command is-
git pull
Leave a Reply