GITHUB NOTES
In Git, a fork refers to the process of a new owner taking over a repository and disconnecting
the source code from previous developers.
After clicking on the fork, a loading screen showing Forking "project" will show a loading
screen.
Now, copy the URL by clicking on the Code option.
Then open the Git Bash.
To make changes in the file, you need to clone the repository by using the command:
$ git clone [Link]
And here, you can see your local clone has been created.
Go into the new example directory, and write "$ cd example".
Let's see how we can sync this repository to the original repository.
Go to the original project on Github.
To know where our current fork is, use the command "$ git remote -v."
Next, we will add an upstream repository using
$ git remote add upstream [Link]
Type git remote -v again to verify the upstream repository you specified for your fork. If your
fork is the origin and the original repository is upstream, then the URLs for the two should be
the same.
Some extra git add functionalities are:
git add - A: All changes happen at once.
git add: The current directory and its subdirectories are staged with new files and
modifications without deletions.
git add -u: Deletes or modifies old files but does not create new ones.
git config
The git config command sets configuration values. This command will enable your computer
to create your Git name and email before you begin working with Git. This command
modifies git configuration files. Information such as your username, default editor, and email
is stored in these files.
There is a file named .gitconfig. To see the content of the .gitconfig file, write the command
"$ cat .gitconfig". This will show the global content of the file.
Now, go back to the root directory and type "$ git config –global -l" this will list the globally
present content in the computer.
We can remove any value from the file using the command
$git config --global --unset [Link]
Adding the value using the command
$git config --global [Link] "value"
How do forks and clones differ in Git?
The fork creates a separate copy of the Git repository. The difference between cloning and
forking is that clones make a linked copy that continues to synchronize with the target
repository.
Is it necessary to git init before cloning?
It is usually used when setting up a new Git repository and already has code. You do not
need git init to clone a project if you are cloning it.
What does git add and git commit mean?
git add creates a staging area for the modified versions of files in your working directory.
With git commit, you make a permanent snapshot of your repository that contains a unique
identifier based on everything in the staging area.
How does git config -- list work?
It will display all Git config properties within the varying scopes of all Git files. Another Git
config scope may have overridden the value displayed.
git log
You can examine the history of your code with git since it tracks every commit over time. To
navigate your local repository, you will need to use CLI tools, such as git log, to view the Git
commit history.
git diff
You often use git diff and git status to analyze your file changes. You can check the status of
your files using the git diff command. git diff shows you the exact differences in your files,
the working directory changes, and the staging changes. Diff is the very definition of
difference.
Is it necessary to git add every time?
git commit -am "message" will add everything that was modified to the commit without you
having to use git add every time.
What is the difference between a git diff and a git status?
It's important to note that git diff is specifically made for comparisons, and it's very powerful
at it: it can compare commits, branches, a single file across revisions or branches, etc. GitHub
status, however, reports on the status of the working tree.