Useful git commands
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
.gitignorefile 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
.gitignorefile alone usinggit add .gitignoreand then commit usinggit commit -m ".gitignore commit" - push the commits using
git push -u origin masterusegit pull origin master --allow-unrelated-historiesif 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
Never miss a story from us, subscribe to our newsletter