GIT Knowledge Area
1. What is the command to check the git version?
2. what is the command to create a new git repository?
3. What is the command used to check the changed files in our local branch ?
4. What do staged files mean?
5. What is the command to add a modified file into git?
6. What is the command to add all the changed files into git?
- git add .
- git add --all
7. What does commit mean?
8. What is the command to add commits?
9. what does git status --short say?
10. What do??, M, D, A refer in git status --short command?
- ?? - untracked files
- M - modified files
- D - deleted files
- A - Files added to stage
11. How to check the history of the commits?
12. How to get a detailed description of what each command does?
- git <command> -help
- git help --all
13. How to clone the repository into your local?
14. What does a git fetch do?
15. What does git merge refer to?
16. What does git pull do?
17. What does git rebase do?
18. What does git push refer to?
19. What does git revert do?
20. What does git stash do?
21. What is a branch in git?
22. How to create a new branch in git?
23. How do you move into the specific branch?
24. What does the git add command use for?
25. What does git commit -a refer to?
26. What does --all do?
27. What does git checkout -b <branch name> do?
28. What is the command to delete a branch?
29. what is the command to merge the branch changes?
30. What does cherry-pick refer to?
31. What is the purpose of .gitignore command?
32. How to create .gitignore file in the root directory?
33. How to add ignore all files with extension log?
34. How do you ignore all files in a specific folder?
35. What is SSH?
36. What does SSH do?
37. What does git log --oneline
38. What does git revert do?
39. what does git reset do?
40. What is the code for git reset?
41 what does amend do?
- modify the latest commit
- If we want to change the commit message of the previous commit we can add the command below
- git conmit --amend - m "commit message"
How to initialize the git repository?
using the git init command
git init
The difference between git pull and git fetch
git pull: is used to get and download content from a remote repository and immediately update the local repository to match that content
git fetch: really only downloads new data from a remote repository — but it doesn’t integrate any of this new data into your working files. Fetch is great for getting a fresh view of all the things that happened in a remote repository. It gives what everybody else is doing with the repository at that time.
What is the purpose of a .gitignore file?
it specifies the files that need to be ignored which means the files do not need to commit to remote repo.
How to create a branch in git using the git command?
Use git branch branch_name
How to checkout to a branch?
git checkout branch_name
What is a git commit?
git commit record changes to the repository. It includes a snapshot of changes, author, timestamp, unique identifier
What is git rebase?
- We are working in our branch.
- We have already multiple commits
- We understand that the master branch also updates with new commits
- We need to integrate those commits with our branch
- We run the below command
//feature is our branch
//main is the master branch
git checkout feature
git rebase main
6. What happens here is this first take our branch into initial stage (The soon after create branch)
7. It will first integrate master branch commits separately.
8. On top of that it will integrate out commits separately.
9. Here disadvantage is history re write
10. Advantage is we can see each commit separately
8. What is git merge?
- We are working in our branch.
- We have already multiple commits
- We understand that master branch also update with new commits
- We need to integrate those commits with our branch
- We run below command
//feature is our branch
//main is the master branch
git merge feature main
6. It will update our branch with main branch commits.
7. It will show as one single merge commits even there are multiple commits
8. That single merge commit is added on top of our commits
9. Disadvantage here is we cannot see the history since it is a single merge commit
https://www.atlassian.com/git/tutorials/merging-vs-rebasing
9. How git stash works?
- takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy
- When you are working on your branch and you realized that master branch is changed with new content
- You do the git stash (Save your work for later use)
- Then git pull origin master
- Then git unstash (Add your changes on top of master branch changes)
10. Git commands from checkout to push
git clone reponame
git fetch ( check the latest brnaches, changes , etc…)
git checkout branchname
git pull origin master
//// Do the code changes on your branch
git add .
git add specificfilaname.java/txt/...
git commit -m "commit message"
git push
// create pull request from bit bucket
11. What is git pull origin master?
Update local branch with the latest updates from the master branch
12. What is conflict?
When two branches have done changes to the same line in a file.
//checkout to the branch
git status
// indellij idea
VCS-> Resolve Conflicts
Dialog appears
Select file
Click on merger
It will open side by side window
Master branch and local branch changes
Check line by line in conflicted areas and manuall add or remove them
After everything is done
git commit
Verify_etc.spec.ts
and verify_etc.spec.ts
as the same file.git mv
command forces Git to track the rename operation, including changes in case.Solution: Rename with Temporary Name
Rename to a Temporary Name:
This explicitly tells Git to rename the file.
Rename to the Desired Name:
Commit the Changes:
Push the Changes:
Comments
Post a Comment