Getting Started
Instantiating Repositories
-
Create a new repository by instantiating it through:
git init
-
Copy an existing project by cloning the repository through:
git clone <url>
Central Repositories
-
To instantiate a central repository a
--bare
flag is required. -
Bare repositories don't allow file editing or committing changes.
-
Create a bare repository with:
git init --bare project-name.git
Instantiate workflow with clone
- Create a project in your user namespace.
- Choose to import from Any Repository by URL and use https://gitlab.com/gitlab-org/training-examples.git.
- Create a '
Workspace
' directory in your home directory. - Clone the '
training-examples
' project.
mkdir ~/workspace
cd ~/workspace
git clone [email protected]:<username>/training-examples.git
cd training-examples
Git concepts
Untracked files
New files that Git has not been told to track previously.
Working area
Files that have been modified but are not committed.
Staging area
Modified files that have been marked to go in the next commit.
Committing Workflow
- Edit '
edit_this_file.rb
' in 'training-examples
' - See it listed as a changed file (working area)
- View the differences
- Stage the file
- Commit
- Push the commit to the remote
- View the Git log
# Edit `edit_this_file.rb`
git status
git diff
git add <file>
git commit -m 'My change'
git push origin master
git log
Note
-
git fetch
vsgit pull
- Pull is
git fetch
+git merge