gituto/doc/beginning_with.org

1.7 KiB

Pro Git book notes: git basics

init or clone a repository

Use git followed by an argument:

  • init to create a local repository
  • clone to make a copy of a existing repository

The following code will clone a repository and create a directory with the name of the repository

  git clone https://gitdisroot.org/repository_name

To clone and change the target directory name, use an additional argument with the name ("new_directory") of the directory that will be used after the link of the repository to be cloned:

  git clone https://gitdisroot.org/repository_name new_directory

To add a file use add followed by the name of the file

First, check the repository status, to verify changes in files, or to know if new files need to be added:

  git status
   git add 'file'

Commit and push changes to remote repository

  git commit -m "Message here!"

Share your local changes with the remote repository using git push:

  git push

Removing a file from the repository

  git rm 'file'

Moving a file

  git mv 'file' 'file2'

Which is equivant to mv in bash:

   mv file file2

List files under version control

  git ls-tree -r master --name-only