GIT Flashcards
To “squash”
The act of “squashing” your commits means that you combine multiple existing commits into a single one. If you should do this or avoid it is - to some extent - a question of preference: in some teams, for example, squashing commits is the preferred way to merge a feature branch back into a long-running branch like “master” or “main”.
Order of steps?
Branch????
1. Add
2.Commit
3.pull( FETCH+MERGE)!!!!!!!!!!!!!!!!!!!!!!!!!
4. Push?
Git
Git is an open-source version control system often used for source code management
How to integrate changes from one branch onto another in GIT
1.Rebasing - the linear process of merging
Rebasing is the process of combining or moving a sequence of commits on top of a new base commit.
- Merging
Git commands
1.CLONE
git clone URL
Git clone is a command for downloading existing source code from a remote repository (like Github, for example). In other words, Git clone basically makes an identical copy of the latest version of a project in a repository and saves it to your computer.
2.BRANCH
-By using branches, several developers are able to work in parallel on the same project simultaneously
2.1. Creating a new branch locally
git branch <branch-name></branch-name>
2.2.Switching from one branch to another
git checkout <name-of-your-branch></name-of-your-branch>
*The changes in your current branch must be committed or stashed before you switch
*The branch you want to check out should exist in your local
*create and switch to a branch at the same time:
git checkout -b <name-of-your-branch></name-of-your-branch>
2.3. Push the new branch into the remote repository
git push -u <remote> <branch-name>
2.3. Viewing branches:
git branch or git branch --list</branch-name></remote>
2.4. Deleting a branch:
git branch -d <branch-name></branch-name>
- GIT STATUS
- ADD–> add the files to the staging area
git add file
git add -A (all) - COMMIT
Git commit is like setting a checkpoint in the development process which you can go back to later if needed.
git commit -m “commit message”
Git commit saves your changes only locally.!!!!!
- PUSH
Git push uploads your commits to the remote repository.
git push <remote> <branch-name>
However, if your branch is newly created, then you also need to upload the branch with the following command:
Statuls of the file: Staged, unstaged, untracked</branch-name></remote> - PULL
git pull <remote>
used to get updates from the remote repo. This command is a combination of git fetch and git merge which means that, when we use git pull, it gets the updates from remote repository (git fetch) and immediately applies the latest changes in your local (git merge).</remote> - REVERT
first we need to use git log – oneline:
Then we just need to specify the hash code next to our commit that we would like to undo:
git revert 3321844
- MERGE
- STASH????