MNikolovski

Git first

Sep 8th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. git --version (to check the version of git installed)
  2.  
  3. GIT WORKFLOW LIFE CYCLE:
  4. - Working Directory;
  5. - Staging Area;
  6. - Repository (.git folder)
  7. - Remote.
  8.  
  9. Git requires two bits of information before we can do anything:
  10. -username
  11. git config --global user.name
  12. -email
  13. git config --global user.email
  14.  
  15. The process of getting a copy of a repository on GitHub onto the local system is called CLONING a repository.
  16. Cloning is done with the command: git clone "url"
  17. The "git clone" command automatically sets up a relationship back to the repository on GitHub and named that reference "origin".
  18.  
  19. We can ask git about the state of the repository with the command: git status.
  20.  
  21. The "working directory" is where we do all the work and that Git monitors for changes.
  22.  
  23. An "untracked file" is a file in our working directory that hasn't been added to Git yet.
  24. We add files to Git with the command: git add "nameOfTheFile"
  25. We remove files from Git with the command: git reset "nameOfTheFile"
  26.  
  27. Files in the staging area are files that are waiting to be committed.
  28.  
  29. We can commit files with the command: git commit.
  30. When committing, we usually use -m "Some message" to add a message to the commit.
  31. After committing, the file is moved from the staging area to the local repository.
  32.  
  33. For deleting a local repository: rm -rf "name of the repository"
  34. For stopping Git from managing our folder we can type: rm -rf .git , in the project's folder.
  35.  
  36. We can update the files to the remote directory with the command: git push origin master
  37.  
  38. =================
  39. Creating a new repository locally
  40. =================
  41. git init "name of the project"
  42.  
  43. =================
  44. Adding an existing project to Git
  45. =================
  46. To add an existing project to git, we enter in the project's folder and type the command: git init
  47. This will add the current folder to git.
  48. After this, we use the "git add ." command to add all the files to Git, and after that, we use the "git commit" command to commit all the changes to Git.
  49. After this, we follow the commands below.
  50.  
  51. =================
  52. Adding an existing project to GitHub
  53. =================
  54. git remote add origin "remote repository URL"
  55. git push origin master
Add Comment
Please, Sign In to add comment