Basic Git Commands
List of some basic Git commands
- Configure the author name and email at the starting by using:
git config --global user.name "Ankita Singh"
git config --global user.email ankita@example.com
2. Initializing a new repository:
git init
3. Create a working copy of a local repository:
git clone /path/to/the/working/directory
4. Create a working copy of a remote repository:
git clone username@host:/path/to/the/working/directory
5. Add files to staging area:
git add .
git add <filename>
6. Commit changes to head:
git commit -m "your commit message"
7. Push all changes to the master branch of remote repository:
git push origin master
8. Check status of files changed and those are still need to add or commit:
git status
9. Connect local repository to remote server:
git remote add origin <server>
10. Create new branch:
git checkout -b <branch_name>
11. Switch to an existing branch:
git checkout <branch_name>
12. List all the branches:
git branch
13. Push the branch to remote repository:
git push origin <branch_name>
14. Push all branches to remote repository:
git push --all origin
15. Get latest version of a repository:
git pull
Pull remote repository to local branch:
git pull <branch_name> <remote_branch/url>