-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSteps.txt
60 lines (44 loc) · 2.96 KB
/
Steps.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
1. Create a Repository in Git Hub
2. Clone the repository to your local system.
3. You would be able to see the folder created in the name of the repository
4. Navigate to that folder, you should be able to see readme file, if you have created during the creation of the repository
5. Git Add -- To add the file (Working Folder)
6. Git Commit -- To commit the changes to Local repository (Staging Environment)
7. Git Push -- To push the changes to the remote repository (Remote repository)
8. Git Log to view all the changes made
--- To ignore Files
9. create a ignore file either in windows explorer or in command prompt
10. command to do in cmd is "touch .gitignore"
-- Changes Made to main branch after creating "New Branch one", and after that we will merge both the branches
11. Head is the reference to the recent commit.
12. Git Show head
13. To get the differnce between two commits
git difftool "Old version" "New version"
git difftool Head~2 Head~1 [Head -- Head~1 -- Head~2 -- Head~3 ....]
--- Branches
14. Branches are used when a new feature needs to be added or doing some experimental activites with out affecting the original branch
15. Git Branch -- shows the available branches
16. Git Branch BranchName -- Creates a new branch with the branch name provided
17. Git Checkout BranchName -- Focus is now moved to the new Branch, now you can do the required changes to the code.
18. Create a branch and checkout in one go: git checkout -b "Branch Name"
19. To delete a branch go to another branch and then
git branch -d "Branch Name".
-- Merge
Merge is an operation to integrate changes from one branch to another branch by adding a new commit
20. After creating a new branch and working on it, you need to merge with the main branch
21. Checkout the main branch, then "git merge BranchName"
22. If files does not have the same line changes, it automatically merges, if changes are on the same line then auto merge does not work, so we need to merge it manually.
23. After merging manually add that file and commit the changes.
tips: git log --all --decorate --oneline
git branches --graph --oneline
-- Rebase
Rebase is an operation to integrate changes from one branch to another. It is an alternative to the Merge command.
24. git rebase main -- is the syntax to rebase the master. This is merge the changes of current branch with the main branch
Benefits:
Unnecessary merge history
some times it can be dangerous, dont do rebase for Master brances
-- Undo/ Revert changes
25. if the change is only in local work area and want to undo, just go for "git checkout -- filename" if more files then "git checkout -- ."
26. if changes are commited, then use "git revert commitId" or "git revert -n commitId"
difference between with -n and with out is, with out n will reset and commit, with -n will only reset and we will have to explicitly commit the changes
27. Reset, will remove all the commits will the specified version, "get reset CommitId", it is very powerful, and also dangerous