https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control
https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud
1) view all of your settings and where they are coming from using:
$ git config --list --show-origin
f 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
user.email=johndoe@example.com
color.status=auto
color.branch=auto
color.interactive=auto
color.diff=auto
...
2) Setting your Identity
The first thing you should do when you install Git is to set your user name and email address. This is important because every Git commit uses this information, and it’s immutably baked into the commits you start creating:
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
3) Setting your Editor
. If not configured, Git uses your system’s default editor.
If you want to use a different text editor, such as Emacs, you can do the following:
$ git config --global core.editor emacs
4) Checking specific Git value
You can also check what Git thinks a specific key’s value is by typing git config <key>
:
$ git config user.name
John Doe
5) Initializing a Repository in an Existing Directory
If you have a project directory that is currently not under version control, and you want to start controlling it with Git, you first need to go to that project’s directory.
for Linux:
$ cd /home/user/my_project
and type:
$ git init
This creates a new subdirectory named .git
that contains all of your necessary repository files — a Git repository skeleton. At this point, nothing in your project is tracked yet. See Git Internals for more information about exactly what files are contained in the .git
directory you just created.
If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit. You can accomplish that with a few git add
commands that specify the files you want to track, followed by a git commit
:
$ git add *.c
$ git add LICENSE
$ git commit -m 'Initial project version'
We’ll go over what these commands do in just a minute. At this point, you have a Git repository with tracked files and an initial commit.
6) Cloning an Existing Repository
Git receives a full copy of nearly all data that the server has. Every version of every file for the history of the project is pulled down by default when you run git clone
You clone a repository with git clone <url>
. For example, if you want to clone the Git linkable library called libgit2
, you can do so like this:
$ git clone https://github.com/libgit2/libgit2
That creates a directory named libgit2
, initializes a .git
directory inside it, pulls down all the data for that repository, and checks out a working copy of the latest version. If you go into the new libgit2
directory that was just created, you’ll see the project files in there, ready to be worked on or used.
If you want to clone the repository into a directory named something other than libgit2
, you can specify the new directory name as an additional argument:
$ git clone https://github.com/libgit2/libgit2 mylibgit
That command does the same thing as the previous one, but the target directory is called mylibgi
The following are some of the most common Git commands used:
1. git init – Initialize a local Git repository
2. git clone – Create a local copy of a remote repository
3. git add – Add files for staging
4. git commit – Commit the staged files
5. git push – Push the committed files to a remote repository
6. git pull – Fetch and merge a remote repository into the local repository
7. git branch – Manage existing branches in the repository
8. git checkout – Switch to another branch in the repository
9. git merge – Merge branches together in the repository
10. git status – Check the status of files in the repository
No hay comentarios:
Publicar un comentario