Useful git commands
![Useful git commands](https://e7.pngegg.com/pngimages/191/974/png-clipart-github-repository-git-project-commit-github-angle-logo-thumbnail.png)
This page contains few useful git commands
- Create repository in github
- Go to you local project folder
- Add README.md file using
echo "Hello" >> README.md
-
Add
.gitignore
file manually and add the below content if your project is eclipse maven project# Eclipse .classpath .project .settings/ # Intellij .idea/ *.iml *.iws # Mac .DS_Store # Maven log/ target/
- Add remote repository using
git remote add origin https://github.com/ayosuva/test.git
- create branch using
git branch -M master
- Add
.gitignore
file alone usinggit add .gitignore
and then commit usinggit commit -m ".gitignore commit"
- push the commits using
git push -u origin master
usegit pull origin master --allow-unrelated-histories
if you have initialized repo in github and also committed locally - Now add the all others files using
git add .
- This will add only the required file and it will ignore the file/folders that we have mentioned in the .gitignore file - commit using
git commit -m ".gitignore commit"
- push the commits using
git push -u origin master