Sample git operations
- git clone <full path of git branch>
- git fetch && git checkout <name of branch>
- git pull
- git status
- git add .
- git status
- git commit -m "comment"
- git push origin <name of branch>
Explanation:
1. git clone <full path of git branch>
Clones the repository from remote server to the local computer
2. git fetch && git checkout <name of branch>
Prepares local repository for updates
3. git pull
Downloads any changes that were performed on the remote repository to local repository
4. git status
Shows which files in the local repository have been updated along with the files that were registered and not registered for updates
5. git add .
Registers all files that were modified in the local repository
You may also specify individual files by executing git add <filepath>
6. git status - look at item 4
7. git commit -m "comment"
Commits all the files that were added using git add to the local repository. This is also called as Staging
8. git push origin <name of branch>
Updates the remote repository with the changes that were committed in local repository
Common commands in git:
1. Show me what files are changed
git status
2. Stage the files (-A stages all modified files)
git add -A
3. To get to the latest committed files
git checkout -- .
4. Version of git
git --version
5. Configure git with username and email
git config --global user.name "username"
git config --global user.email "youremail@address"
6. Compare updates done to a file in local repository
git diff <name of file>
No comments:
Post a Comment