-
Notifications
You must be signed in to change notification settings - Fork 0
add question-answer files #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AshokaJS
wants to merge
2
commits into
main
Choose a base branch
from
ashok
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| question 1 :- How to set multiple remote repositories for the same project? Explain the use case. you should have a working demo of it. | ||
|
|
||
| answer :- we can configure a project to push and pull from multiple remote repositories. This is useful for: | ||
|
|
||
| i) Backup repositories (e.g., GitHub + GitLab). | ||
| ii) Team collaboration across different platforms. | ||
| iii) Deploying code to multiple servers. | ||
|
|
||
| command for setting remote repositories is: | ||
| i) git remote set-url --add --push origin git@github.com:username/repo.git | ||
| ii) git remote set-url --add --push origin git@gitlab.com:username/repo.git | ||
|
|
||
|
|
||
| working demo of remote repositories:- | ||
| --git add . | ||
| --git commit -m "first commit" | ||
| --git push origin main | ||
| --git push gitlab master | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| question 2 :- How to un-stage changes from the staged area. write command for it. | ||
|
|
||
| answer :- To un-stage changes (move files from the staged area back to the working directory) in Git, use the following commands: | ||
| i) git restore --staged <file-name> | ||
| ii) git restore --staged . | ||
| iii) git reset HEAD | ||
|
|
||
| all the above mentioned commands move changes back to the working directory. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| question 3 :- What happens when a file is deleted in the main branch and updated in a feature branch, and how is this handled during a merge? | ||
|
|
||
| answer :- When a file is deleted in the main branch and modified in a feature branch, Git encounters a conflict during merging because it cannot automatically decide whether to: | ||
|
|
||
| i) Keep the deleted state from main, or | ||
| ii) Apply the modifications from the feature branch. | ||
|
|
||
| Resolving the Conflict | ||
| i) keep the deleted file | ||
| ii) keep the updated file | ||
|
|
||
| key takeaways: | ||
| i) git cannot automatically resolve a delete/modify conflict. | ||
| ii) we must choose to either keep or delete the file. | ||
| iii) After resolving, commit the changes to complete the merge. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| question 4 :- What does the git ls-files command do, and what information does its output provide regarding the state of files in a Git repository? | ||
|
|
||
| answer :- The git ls-files command provides a list of files that are currently being tracked by Git in a repository. It shows the files in the staging area (index) and working directory, helping you understand which files Git is currently aware of. | ||
|
|
||
| command :- git ls-files | ||
|
|
||
| This command outputs the list of tracked files in the repository, which are: | ||
|
|
||
| i) Staged files (those added with git add). | ||
| ii) Committed files (files already committed to the repository). | ||
| iii) Unmodified files (those unchanged since the last commit). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| question 5 :- Under what conditions will Git consider a file that has been deleted as being renamed, and what criteria does Git use to determine that a new file is a renamed version of the deleted file? | ||
|
|
||
| answer : In Git, renaming a file is a special case. Git doesn’t have a dedicated rename command. Instead, it detects renames through the comparison of file content and the file’s history. When a file is deleted in one commit and modified or added with similar content in another, Git may treat it as a rename. | ||
|
|
||
| Conditions for Git to Recognize a Rename | ||
|
|
||
| i) File content similarity. | ||
| ii) File Deletion and Addition on Different Branches. | ||
| iii) Not Too Much Change in Content. | ||
| iv) File path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| question 6 :- Why is it not possible to create two branches with the names fix and fix/bug in a Git repository, and what causes this conflict? | ||
|
|
||
| answer : In Git, the reason you cannot create two branches with the names fix and fix/bug is due to the way Git handles branch naming conventions and file paths. Specifically, Git uses a slash (/) in branch names to denote a hierarchical structure, which can lead to conflicts. | ||
|
|
||
| i) In Git, branch names can have slashes (/) to create a "folder-like" structure. For example, you can have:- | ||
|
|
||
| a) fix (a branch named fix). | ||
|
|
||
| b) fix/bug (a branch named bug under the fix directory, which is logically a sub-branch). | ||
|
|
||
| ii) Git's Internal Directory Structure:- | ||
|
|
||
| Git internally stores branches in the .git/refs/heads/ directory (or a similar structure for remotes). Git treats slashes as a path separator. So, when you create a branch like fix/bug, Git internally sees it as a folder called fix with a file named bug inside it, making it a hierarchical branch name. | ||
|
|
||
| iii) Conflict When Naming fix and fix/bug:- | ||
|
|
||
| a) If you attempt to create a branch named fix, it will be created as a file in .git/refs/heads/fix. | ||
|
|
||
| b) If you try to create a branch named fix/bug, Git will try to create a file in .git/refs/heads/fix/bug, but since fix is already a valid directory (a "folder" for Git), Git cannot create a second branch at fix and fix/bug because it sees the fix branch as an existing directory. | ||
|
|
||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.