The purpose of Git is to manage a project, or a set of files, as they change over time. Git stores this information in a data structure called a repository. A git repository contains, among other things, the following: A set of commit objects. A set of references to commit objects, called heads..
- Project path
- Project name
- Project description (optional)
- Visibility Level
- Private : Project access must be granted explicitly to each user.
- Internal : The project can be accessed by any logged in user.
- Public : The project can be accessed without any authentication.
Git global setup
git config --global user.name "John Doe"
git config --global user.email "[email protected]"
Checking Your Settings
If you want to check your configuration settings, you can use the git config --list command to list all the settings Git can find at that point:
$ git config --list
user.name=John Doe
[email protected]
color.status=auto
color.branch=auto
color.interactive=auto
color.diff=auto
git clone https://gitlab.com/John Doe/my-pro.git
cd my-pro
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
cd existing_folder
git init
git remote add origin https://gitlab.com/John Doe/my-pro.git
git add .
git commit -m "Initial commit"
git push -u origin master
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/John Doe/my-pro.git
git push -u origin --all
git push -u origin --tags
A commit is like a snapshot of all the files in your project at a particular point in time.
- Let's commit a change to the README file.
- In your repository's list of files, click README.md.
- Above the file's content, click
- On the Edit file tab , type some information about yourself.
- Above the new content, click Preview changes.
- Review the changes you made to the file. You'll see the new content in green.
- At the bottom of the page, type a short, meaningful commit message that describes the change you made to the file.
- Below the commit message fields, decide whether to add your commit to the current branch or to a new branch. If your current branch is master, you should choose to create a new branch for your commit and then create a pull request.
- Click Propose file change.
First, you create your branch locally:
git checkout -b <branch-name> # Create a new branch and check it out
The remote branch is automatically created when you push it to the remote server. So when you feel ready for it, you can just do:
git push <remote-name> <branch-name>
Where is typically origin, the name which git gives to the remote you cloned from. Your colleagues would then just pull that branch, and it's automatically created locally. Note however that formally, the format is:
git push <remote-name> <local-branch-name>:<remote-branch-name>
But when you omit one, it assumes both branch names are the same. Having said this, as a word of caution, do not make the critical mistake of specifying only : (with the colon), or the remote branch will be deleted! So that a subsequent git pull will know what to do, you might instead want to use:
git push --set-upstream <remote-name> <local-branch-name>
As described below, the --set-upstream
option sets up an upstream branch: