34
loading...
This website collects cookies to deliver better user experience
.git
folder inside. Go ahead and list all the files (and hidden files) in a Git repository. You will see a .git
folder in there. In that folder, Git keeps a record of the commits that have been made, who made them, when, and so on.git init
inside a folder, you create the .git
folder there for the first time. From then on, Git will track everything that happens in your repository..git
folder. Git will set up things so that you can communicate with where you cloned from (for example GitHub) so that later you can send your changes to it (push) or update from it (pull). To clone a repository you need to provide the URL for that repository:$ git clone [URL]
$ git status
On branch feature_1
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: file.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
file2.txt
no changes added to commit (use "git add" and/or "git commit -a")
feature_1
. We have modified a file called file.txt
and there is a new file (file2.txt
) that is not added to Git yet and therefore it is reported as "Untracked".file.txt
, you can use the diff command like this:$ git diff file.txt
diff --git a/file.txt b/file.txt
index be05e9c..163b853 100644
--- a/file.txt
+++ b/file.txt
@@ -1,3 +1,3 @@
Something
Something more
-
+Something else
git log
command is your friend. Although the default output is not so helpful, you can create a good-looking visualization of the log using some additional command arguments. You can even create an alias, so you don't need to write those command arguments each time. Read this article to learn how to do it.$ git show <commit-hash>
$ git checkout <commit-hash>
git switch -
.$ git branch [branch-name]
$ git checkout [branch-name]
$ git pull
Already up to date.
$ git merge [your-branch-name]
git push
simply sends commits you have done locally in your current branch up to the remote repository. However, if this is the first time you are$ git push -u origin my_new_branch
my_new_branch
and this is the first time you are pushing it to the remote repository. Read more about this here.git fetch
asks the remote about the latest developments. It doesn't change your files. It just downloads the history from remote so that you can visualize what has happened on the remote since the last time you synced.