Yosuva
Yosuva Test Automation Engineer at Cognizant

Useful git commands

Useful git commands

This page contains few useful git commands

  1. Create repository in github
  2. Go to you local project folder
  3. Add README.md file using echo "Hello" >> README.md
  4. 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/
    
  5. Add remote repository using git remote add origin https://github.com/ayosuva/test.git
  6. create branch using git branch -M master
  7. Add .gitignore file alone using git add .gitignore and then commit using git commit -m ".gitignore commit"
  8. push the commits using git push -u origin master use git pull origin master --allow-unrelated-histories if you have initialized repo in github and also committed locally
  9. 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
  10. commit using git commit -m ".gitignore commit"
  11. push the commits using git push -u origin master

comments powered by Disqus