Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • F first-contributions
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 322
    • Merge requests 322
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • First Contributions
  • first-contributions
  • Merge requests
  • !9448
An error occurred while fetching the assigned milestone of the selected merge_request.

Add patty22 to contribution

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/paty22/patch-1 into master 6 years ago
  • Overview 0
  • Commits 21621
  • Pipelines 0
  • Changes 171

Created by: paty22

Compare
  • master (base)

and
  • latest version
    6e6c40a0
    21621 commits, 2 years ago

171 files
+ 2263
- 0

    Preferences

    File browser
    Compare changes
.gi‎thub‎
CONTRIB‎UTING.md‎ +53 -0
ISSUE_TE‎MPLATE.md‎ +20 -0
additiona‎l-material‎
git_workflo‎w_scenarios‎
Useful-links-for-f‎urther-learning.md‎ +26 -0
additional-‎material.md‎ +46 -0
amending-a‎-commit.md‎ +48 -0
configuri‎ng-git.md‎ +76 -0
keeping-your-fork-synced‎-with-this-repository.md‎ +40 -0
moving-a-commit-to-a‎-different-branch.md‎ +25 -0
removing-‎a-file.md‎ +23 -0
removing-branch-fro‎m-your-repository.md‎ +31 -0
resolving-merg‎e-conflicts.md‎ +35 -0
reverting-‎a-commit.md‎ +41 -0
squashing-‎commits.md‎ +86 -0
stashing-‎a-file.md‎ +138 -0
undoing-a‎-commit.md‎ +55 -0
transl‎ations‎
additional-m‎aterial.id.md‎ +46 -0
additional-m‎aterial.ko.md‎ +42 -0
additional-mat‎erial.pt_br.md‎ +11 -0
additional-m‎aterial.ru.md‎ +47 -0
additional-m‎aterial.sl.md‎ +46 -0
additional-m‎aterial.ur.md‎ +47 -0
addtional-ma‎terial.cht.md‎ +46 -0
amending-a-‎commit.ko.md‎ +46 -0
amending-a-‎commit.ru.md‎ +45 -0
amending-a-‎commit.sl.md‎ +48 -0
amending-a-‎commit.ur.md‎ +52 -0
configurin‎g-git.ru.md‎ +77 -0
configurin‎g-git.sl.md‎ +77 -0
keeping-your-fork-synced-‎with-this-repository.ko.md‎ +41 -0
keeping-your-fork-synced-wi‎th-this-repository.pt_br.md‎ +40 -0
keeping-your-fork-synced-‎with-this-repository.sl.md‎ +40 -0
moving-a-commit-to-a-‎different-branch.hi.md‎ +26 -0
moving-a-commit-to-a-‎different-branch.ko.md‎ +28 -0
moving-a-commit-to-a-‎different-branch.ru.md‎ +25 -0
moving-a-commit-to-a-‎different-branch.sl.md‎ +25 -0
removing-a‎-file.ru.md‎ +23 -0
removing-a‎-file.sl.md‎ +23 -0
removing-branch-from-‎your-repository.hi.md‎ +32 -0
removing-branch-from-‎your-repository.ko.md‎ +30 -0
removing-branch-from-y‎our-repository.pt_br.md‎ +31 -0
removing-branch-from-‎your-repository.sl.md‎ +30 -0
resolving-merge‎-conflicts.ko.md‎ +43 -0
resolving-merge‎-conflicts.sl.md‎ +34 -0
reverting-a-‎commit.ko.md‎ +35 -0
reverting-a-‎commit.sl.md‎ +39 -0
squashing-c‎ommits.sl.md‎ +94 -0
stashing-a‎-file.sl.md‎ +137 -0
undoing-a-c‎ommit.ko.md‎ +59 -0
undoing-a-c‎ommit.sl.md‎ +55 -0
ass‎ets‎
catala‎n1.png‎ +0 -0
clon‎e.png‎ +0 -0
compare-an‎d-pull.png‎ +0 -0
copy-to-cl‎ipboard.png‎ +0 -0
dt-bran‎ch1.png‎ +0 -0
dt-bran‎ch2.png‎ +0 -0
dt-bran‎ch3.png‎ +0 -0
dt-clo‎ne1.png‎ +0 -0
dt-clo‎ne2.png‎ +0 -0
dt-clo‎ne3.png‎ +0 -0
dt-clo‎ne4.png‎ +0 -0
dt-comm‎it1.png‎ +0 -0
dt-comm‎it2.png‎ +0 -0
dt-publ‎ish1.png‎ +0 -0
dt-publ‎ish2.png‎ +0 -0
dt-sta‎tus.png‎ +0 -0
dt-sy‎nc.png‎ +0 -0
dt-syn‎c2.png‎ +0 -0
dt-syn‎c3.png‎ +0 -0
dt1-cloneto‎desktop.png‎ +0 -0
dt1-com‎mit1.png‎ +0 -0
dt1-com‎mit2.png‎ +0 -0
dt1-create-br‎anch-name.png‎ +0 -0
dt1-create‎-branch.png‎ +0 -0
dt1-downl‎oaded.png‎ +0 -0
dt1-open-gith‎ubdesktop.png‎ +0 -0
dt1-publ‎ish1.png‎ +0 -0
dt1-sig‎n-in.png‎ +0 -0
dt1-sta‎tus.png‎ +0 -0
fork‎.png‎ +0 -0
git-sta‎tus.png‎ +0 -0
gk-bra‎nch.png‎ +0 -0
gk-clo‎ne.png‎ +0 -0
gk-com‎mit.png‎ +0 -0
gk-ed‎it.png‎ +0 -0
gk-ic‎on.png‎ +0 -0
gk-log‎in.png‎ +0 -0
gk-ori‎gin.png‎ +0 -0
gk-pu‎sh.png‎ +0 -0
gk-sta‎ge.png‎ +0 -0
join-slac‎k-team.png‎ +0 -0
pirat‎e.png‎ +0 -0
saasgrids-‎banner.png‎ +0 -0
submit-pull‎-request.png‎ +0 -0
triangle_w‎orkflow.png‎ +0 -0
triangle_work‎flow.pt_br.png‎ +0 -0
vs2017-01-‎clone1.png‎ +0 -0
vs2017-02-‎clone2.png‎ +0 -0
vs2017-03-‎clone3.png‎ +0 -0
vs2017-04-‎branch1.png‎ +0 -0
vs2017-05-‎branch2.png‎ +0 -0
vs2017-06-‎branch3.png‎ +0 -0
vs2017-07-‎branch4.png‎ +0 -0
vs2017-08-‎change1.png‎ +0 -0
vs2017-09-‎commit1.png‎ +0 -0
vs2017-10-‎commit2.png‎ +0 -0
vs2017-11-‎commit3.png‎ +0 -0
vs2017-12-‎commit4.png‎ +0 -0
vs2017-13-‎commit5.png‎ +0 -0
vs2017-14-‎commit6.png‎ +0 -0
vscode-2018-‎08-branch.png‎ +0 -0
vscode-2018-0‎8-changes.png‎ +0 -0
vscode-2018-‎08-clone.png‎ +0 -0
vscode-2018-‎08-clone1.png‎ +0 -0
vscode-2018-‎08-clone2.png‎ +0 -0
vscode-2018-‎08-clone3.png‎ +0 -0
vscode-2018-‎08-commit.png‎ +0 -0
vscode-2018-0‎8-commit1.png‎ +0 -0
vscode-2018-0‎8-gh-auth.png‎ +0 -0
vscode-2018‎-08-push.png‎ +0 -0
transl‎ations‎
README‎.ar.md‎ +0 -0
README‎.bn.md‎ +0 -0
README‎.ca.md‎ +0 -0
README‎.chs.md‎ +0 -0
README‎.cht.md‎ +0 -0
README‎.cs.md‎ +0 -0
README‎.da.md‎ +0 -0
README‎.de.md‎ +0 -0
README‎.eg.md‎ +0 -0
README.en‎-pirate.md‎ +0 -0
README‎.es.md‎ +0 -0
README.‎fa.en.md‎ +0 -0
README‎.fa.md‎ +0 -0
README‎.fr.md‎ +0 -0
README‎.gl.md‎ +0 -0
README‎.gr.md‎ +0 -0
README‎.hb.md‎ +0 -0
README‎.hi.md‎ +0 -0
README‎.id.md‎ +0 -0
README‎.it.md‎ +0 -0
README‎.ja.md‎ +0 -0
README‎.ko.md‎ +0 -0
README‎.lt.md‎ +0 -0
README.mm_‎unicode.md‎ +0 -0
README‎.mr.md‎ +0 -0
README‎.mx.md‎ +0 -0
README‎.nl.md‎ +0 -0
README‎.pl.md‎ +0 -0
README.‎pt-pt.md‎ +0 -0
README.‎pt_br.md‎ +0 -0
README‎.ro.md‎ +0 -0
README‎.ru.md‎ +0 -0
README‎.se.md‎ +0 -0
README‎.sl.md‎ +0 -0
README‎.slk.md‎ +0 -0
README‎.th.md‎ +0 -0
README‎.tr.md‎ +0 -0
README‎.ua.md‎ +0 -0
README‎.ur.md‎ +0 -0
README‎.vn.md‎ +0 -0
Transla‎tions.md‎ +0 -0
.giti‎gnore‎ +0 -0
CODE_OF_C‎ONDUCT.md‎ +0 -0
Contrib‎utors.md‎ +0 -0
LIC‎ENSE‎ +0 -0
READ‎ME.md‎ +0 -0
github-desktop-old-‎version-tutorial.md‎ +0 -0
github-deskto‎p-tutorial.md‎ +0 -0
github-windows-vs‎-code-tutorial.md‎ +0 -0
github-windows-v‎s2017-tutorial.md‎ +0 -0
gitkraken-‎tutorial.md‎ +0 -0
package-‎lock.json‎ +0 -0
.github/CONTRIBUTING.md 0 → 100644
+ 53
- 0
  • View file @ 6e6c40a0

# Contribution guide
Welcome to your first contribution. :heart:
#### Before Contributing:
You need to run it locally on your desktop.
In order to do that:
Move to the desired location where package.json file is located
- Install npm(latest version) -
npm is distributed with Node.js - which means that when you download Node.js,
you automatically get npm installed on your computer.
https://www.npmjs.com/get-npm
- Install all the dependencies used by this project.
Use this command: `install npm`
- Run these final commands to run it locally:
`npm run build`
`npm start`
#### Table Of Contents
- [Code of Conduct](#code-of-conduct)
- [Translation Guide](#translation-guide)
## Code of Conduct
If you want to contribute, you need to know a few things.
[Code of conduct](../CODE_OF_CONDUCT.md)
## Translation Guide
We have some rules for translation. If you make the first translation for your language, you must add your language list on `Translations.md`.
#### Example
`Translations.md`
```markdown
|Country | Translated Link |
| --- | --- |
| English | [English](../README.md) |
| 🇮🇳 India | [Hindi](../translations/README.hi.md) |
| 🇲🇲 Myanmar | [Myanmar Unicode](../translations/README.mm_unicode.md), Myanmar ZawGyi |
```
## TODO
- [ ] Fix the grammar for the contribution guide.
- [ ] Add more examples and more guides.
Thanks! :heart:
.github/ISSUE_TEMPLATE.md 0 → 100644
+ 20
- 0
  • View file @ 6e6c40a0

<!--- Provide a general summary of the issue in the Title above -->
🐞 **Problem**
<!--- Provide a detailed description of the change or addition you are proposing -->
<!--- If it is a feature or a bug, what problem is it solving-->
🎯 **Goal**
<!--- Why is this change important to you? How would you use it? -->
<!--- How can it benefit other users? -->
💡 **Possible solutions**
<!--- Not obligatory, but suggest an idea for implementing addition or change -->
📋 **Steps to solve the problem**
* Comment below about what you've started working on.
* Add, commit, push your changes.
* Submit a pull request and add this in comments - `Addresses #<put issue number here>`
* Ask for a review in comments section of pull request.
* Celebrate your contribution to this project. 🎉
additional-material/git_workflow_scenarios/Useful-links-for-further-learning.md 0 → 100644
+ 26
- 0
  • View file @ 6e6c40a0

# Useful Links
This document is dedicated to all the blog posts, helpful sites, tips and tricks websites that makes our lives easier. That we refer to for all our needs, be it a beginner or an expert. This page should act as an index of all those useful links that would help everybody who is new in the open-source domain or someone who wants to learn more.
## The List
1. [Interactive tutorial to git](https://try.github.io)
2. [git - the simple guide](http://rogerdudler.github.io/git-guide/)
3. [On undoing, fixing, or removing commits in git](http://sethrobertson.github.io/GitFixUm/fixup.html)
4. [Git and GitHub tutorial translated to many languages](https://github.com/Roshanjossey/first-contributions)
5. [Merge Conflicts](https://www.git-tower.com/learn/git/ebook/en/command-line/advanced-topics/merge-conflicts)
6. [Resolving Merge Conflicts](https://githowto.com/resolving_conflicts)
7. [Official Git cheat sheet in many languages](https://services.github.com/on-demand/resources/cheatsheets)
8. [Git cheat sheet from Tower](https://www.git-tower.com/learn/cheat-sheets/git)
9. [Common Git Problems](https://www.codementor.io/citizen428/git-tutorial-10-common-git-problems-and-how-to-fix-them-aajv0katd)
10. [Git Rebase](https://blog.gitprime.com/git-rebase-an-illustrated-guide/)
11. [Beginner's Guide to Rebasing and Squashing](https://github.com/servo/servo/wiki/Beginner%27s-guide-to-rebasing-and-squashing)
12. [Git Cheatsheet that shows correlations between commands and files](http://ndpsoftware.com/git-cheatsheet.html)
13. [How to contribute](https://opensource.guide/how-to-contribute/)
14. [Getting started with Open Source](https://github.com/OpenSourceHelpCommunity/Getting-Started-With-Contributing-to-Open-Sources)
15. [How to contribute](https://github.com/freeCodeCamp/how-to-contribute-to-open-source)
16. [Atlassians Git Tutorials](https://www.atlassian.com/git)
17. [Pull request reviews](https://help.github.com/articles/about-pull-request-reviews/)
18. [Another Interactive tutorial for git](https://learngitbranching.js.org/)
19. [Git commandline cheat-sheet](https://gist.github.com/davfre/8313299)
Keep adding more links, that you find helpful.
additional-material/git_workflow_scenarios/additional-material.md 0 → 100644
+ 46
- 0
  • View file @ 6e6c40a0

# Additional information
We assume that you have already finished with the basic tutorial before coming here. The additional information will give you some information about advanced Git techniques.
### [Amending a commit](amending-a-commit.md)
This document provides information about how to amend a commit on the remote repository.
> Use this when you need to adjust a commit you made.
### [Configuring git](configuring-git.md)
This document provides information about how to configure user details and other options in git.
> Use this to better control your git configurations.
### [Keeping your fork synced with the repository](keeping-your-fork-synced-with-this-repository.md)
This document provides information about how to keep your forked repository up-to-date with the base repository. This is important, as hopefully you and many others will contribute to the project.
> Follow these steps if your fork doesn't have any changes in parent repository.
### [Moving a Commit to a different Branch](moving-a-commit-to-a-different-branch.md)
This document provides information about how to move a Commit to another Branch.
> Take these steps to move a commit to another branch.
### [Removing a File](removing-a-file.md)
This document provides information about how to remove a file from your local repository.
> Follow these steps to learn how to remove a file prior to a commit
### [Removing a branch from your repository](removing-branch-from-your-repository.md)
This document provides information about how to delete a branch from your repository.
> Only do these steps after your pull request get's merged.
### [Resolving Merge Conflicts](resolving-merge-conflicts.md)
This document provides information about how to resolve merge conflicts.
> Take these steps to resolve the annoying merge conflicts.
### [Reverting a commit](reverting-a-commit.md)
This document provides information about how to revert a commit on the remote repository. It comes in handy in case for when you need to undo a commit that has already been pushed to Github.
> Take these steps if you want to reverse a commit.
### [Squashing Commits](squashing-commits.md)
This document provides information about how to squash commits with an interactive rebase.
> Use this if you want to open a PR in an open source project and the reviewer asks you to squash every commit into one, with an informative commit message.
### [Undo-ing a local commit](undoing-a-commit.md)
This document provides information about how to undo a commit on your local repository. This is what you need to do when you feel you've messed up your local repository and wish to reset the local repository.
> Take these steps if you want to undo/reset a local commit.
### [Useful Links](Useful-links-for-further-learning.md)
This document is dedicated to all the blog posts, helpful sites, tips and tricks websites that makes our lives easier. That we refer to for all our needs, be it a beginner or an expert. This page should act as an index of all those useful links that would help everybody who is new in the open-source domain or someone who wants to learn more.
additional-material/git_workflow_scenarios/amending-a-commit.md 0 → 100644
+ 48
- 0
  • View file @ 6e6c40a0

# Amending a Commit
What if you commit a change to your remote repository only to realize later that you have a typo in the commit message or you forgot to add a line in your most recent commit.
How do you edit that? This is what this tutorial covers.
## Changing a recent commit message after you have pushed to Github.
To do this without opening a file:
* Type in the ```git commit --amend -m "followed by your new commit message"```
* Run ```git push origin <branch-name>``` to commit the changes to the repository.
Note: If you type in just ```git commit --amend```, your text editor would open up prompting you to edit the commit message.
Adding the ``-m`` flags prevents it.
## Modifying on a single commit
So, what if we forgot to make a minor change to a file like changing a single word and we have already pushed the commit to our remote repository?
To illustrate here is a log of my commits:
```
g56123f create file bot file
a2235d updated contributor.md
a5da0d modified bot file
```
Let's say I forgot to add a single word to the bot file
There are 2 ways to go about this. The first is to have an entirely new commit that contains the change like so:
```
g56123f create file botfile
a2235d updated contributor.md
a5da0d modified botfile
b0ca8f added single word to botfile
```
The second way is to amend the a5da0d commit, add this new word and push it to Github as one commit.
The second sounds better since it is just a minor change.
To achieve this, we would do the following:
* Modify the file. In this case, I will modify the botfile to include the word I omitted previously.
* Next, add the file to the staging area with ```git add <filename>```
Usually after adding files to the staging area, the next thing we do is git commit -m "our commit message" right?
But since what we want to achieve here is to amend the previous commit, we would instead run:
* ```git commit --amend```
This would then bring up the text editor and prompt you to edit the message. You can decide to leave the message as it was before or change it.
* Exit the editor
* Push your changes with `` `git push origin <branch-name>` ``
That way, both changes would be in one single commit.
additional-material/git_workflow_scenarios/configuring-git.md 0 → 100644
+ 76
- 0
  • View file @ 6e6c40a0

# Configuring git
The first time you tried to commit using git, you might have gotten a prompt like the one below:
```bash
$ git commit
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
```
Git needs to know who you are when you create a commit. When you are working collaboratively, you should be able to see who modified what parts of the project and when, and thus, git has been designed to create commits tied to a name and an email.
There are multiple ways to provide the `git commit` command with your email and name, and we'll go through some of them below.
### Global Config
When you store something in the global config, it is accessible system wide in all the repositories you work on. This is the preferred way and works for most use cases.
To store something in the global config, you use the `config` command as follows:
`$ git config --global <variable name> <value>`
In the case of user details, we run it as follows:
```
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
```
### Repository Config
As the name says, these configurations are scoped to your current repository. If you want to commit to a particular repository, say, a work related project, with your company's email, then you could use this method.
To store something in the repository config, you use the `config` command by emitting the `--global` flag as follows:
`$ git config <variable name> <value>`
In the case of user details, we run it as follows:
```
$ git config user.email "you@alternate.com"
$ git config user.name "Your Name"
```
### Command-line Config
These type of configurations are scoped to the current command only. All git commands take `-c` arguments before the action verb to set temporary configuration data.
To store something in the command line config, run your command as follows:
`$ git -c <variable-1>=<value> -c <variable-2>=<value> <command>`
In our example, we would run the commit command as follows:
`git -c user.name='Your Name' -c user.email='you@example.com' commit -m "Your commit message"`
### Note on Precedence
Among the three methods described here, the precedence order is `command-line > repository > global`. This means that, if a variable is configured in the command-line as well as globally, the command-line value would be used for the operation.
## Beyond User Details
We have dealt with only the user details till now while working with the config. However, there are several other configuration options available. Some of them are:
1. `core.editor` - to specify the name of the editor used for writing commit messages, etc.
2. `commit.template` - to specify a file on the system as the initial commit template.
3. `color.ui` - to specify a boolean value for using colors in git's output.
We have abstracted some details for ease of understanding. For further reading, head over to [git-scm.com](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration).
additional-material/git_workflow_scenarios/keeping-your-fork-synced-with-this-repository.md 0 → 100644
+ 40
- 0
  • View file @ 6e6c40a0

# Keeping your fork synced with this repository
First, the flow for a full sync should be understood, which is important. In this schema, there are 3 different repos: my public repo on Github `github.com/Roshanjossey/first-contributions/`, your fork of the repo on GitHub `github.com/Your-Name/first-contributions/` and your local machine's repo from which you are suppose to work. This kind of cooperation is typical for open source projects and called `Triangle Workflows`.
<img style="float;" src="../../assets/triangle_workflow.png" alt="triangle workflow" />
To keep your two repos up-to-date with my public repo, so first we have to fetch and merge the public repo with your local machine's repo.
Our second move will be to push your local repo to your GitHub fork. As you've seen earlier, it's only from your fork that you can ask for a "pull request". So your GitHub fork is the last repo to be updated.
Now, let's see how to do it:
First, you must be on your master branch. To know which branch you are on, check the first line of:
```
git status
```
if you are not already on master:
```
git checkout master
```
Then you should add my public repo to your git with `add upstream remote-url`:
```
git remote add upstream https://github.com/Roshanjossey/first-contributions
```
This is a way of telling git that another version of this project exists in the specified url and we're calling it `upstream`. Once your git has a name let's fetch the latest version of the public repository:
```
git fetch upstream
```
You've just fetched the latest version of my fork (`upstream` remote). Now, you need to merge the public repository into your master branch.
```
git rebase upstream/master
```
Here you're merging the public repository with your master branch. Your local machine's master branch is now up-to-date. Lastly, if you push your master branch to your fork, your GitHub fork will also have the changes:
```
git push origin master
```
Notice here you're pushing to the remote named `origin`.
So by now or at this point, all your repositories are up-to-date. Well done! You should do this, everytime your GitHub repo tells you that you are a few commits behind.
additional-material/git_workflow_scenarios/moving-a-commit-to-a-different-branch.md 0 → 100644
+ 25
- 0
  • View file @ 6e6c40a0

# Moving a commit to a different branch
What if you commit a change, and then realize that you committed to a different branch?
How can you change that? This is what this tutorial covers.
## Moving the latest commits to an existing branch
To do this, type:
```git reset HEAD~ --soft``` - Undoes the last commit, but leave the changes available.
```git stash``` - Records the state of the directory.
```git checkout name-of-the-correct-branch``` - Switches to another branch.
```git stash pop``` - Removes latest stashed state.
```git add .``` - Or try adding individual files.
```git commit -m "your message here"``` - Saves and Commits the changes.
Now your changes are on the correct branch
### Moving the latest commits to a new Branch
To do this, type:
```git branch newbranch``` - Creates a new Branch. Saving all the Commits.
```git reset --hard HEAD~#``` - Move master back by # commits. Remember, these commits will be gone from master
```git checkout newbranch``` - Goes to the branch you created. It will have all the commits.
Remember: Any changes not committed will be LOST.
additional-material/git_workflow_scenarios/removing-a-file.md 0 → 100644
+ 23
- 0
  • View file @ 6e6c40a0

# Removing a file from Git
Sometimes, you may want to remove a file from Git but not delete it from your computer. You can achieve this by using the following command:
``git rm <file> --cached``
## So what happened?
Git will no longer keep track of changes in the removed file. As far as Git knows, it's as if you had deleted the file. If you were to locate the file in your file system, you will notice that it's still there.
Notice that in the example above, the flag `--cached` is used. If we didn't add this flag, Git will remove the file from not just the repo, but from your file system too.
If you commit the change with `git commit -m "Remove file1.js"` and pushed it to the remote repository using `git push origin master`, the remote repository will remove the file.
## Additional features
- If you want to remove more than one file, you can include them all in the same command:
`git rm file1.js file2.js file3.js --cached`
- You can use a wildcard (*) to remove similar files. For example, if you would like to remove all .txt files from your local repository:
`git rm *.txt --cached`
additional-material/git_workflow_scenarios/removing-branch-from-your-repository.md 0 → 100644
+ 31
- 0
  • View file @ 6e6c40a0

# Remove a branch from your repository
If you have followed the tutorial up-to-now, our `<add-your-name>` branch has finished its purpose, it is time to delete it from your local machine's repo. This isn't necessary, but the name of this branch shows its rather special purpose. Its life can be made correspondingly short.
First, let's merge your `<add-your-name>` to your master, so to go to your master branch:
```
git checkout master
```
Merge `<add-your-name>` to master:
```
git merge <add-your-name> master
```
Remove `<add-your-name>` on your local machine's repo:
```
git branch -d <add-your-name>
```
You have now deleted your local machine's `<add-your-name>` branch and everything looks neat and tidy.
Though, at this point, you should still have the `<add-your-name>` branch in your GitHub fork. However, before you delete this, remember that you have sent a "Pull request" to my repo from this remote branch. So unless I've already merged it, don't delete this branch.
However, if I have merged your branch and you want to delete the remote branch, use:
```
git push origin --delete <add-your-name>
```
Now, you know how to tidy your branches.
With time, many commits will be added to my public repo. And the master branches of your local machine and of your GitHub fork won't be up-to-date. So in order to keep your repositories synchronized with mine, follow the steps below.
#### [Keeping your fork synced with the repository](keeping-your-fork-synced-with-this-repository.md)
additional-material/git_workflow_scenarios/resolving-merge-conflicts.md 0 → 100644
+ 35
- 0
  • View file @ 6e6c40a0

# What is a merge conflict?
When you try to merge another branch into your current working branch, you are taking changes from another context and combine them with your current working files.
If two people changed the same lines in that same file, or if one person decided to delete it while the other person decided to modify it, Git simply cannot know what is correct. Git will then mark the file as having a conflict - which you'll have to solve before you can continue your work.
# How to resolve a merge conflict?
When faced with a merge conflict, git will mark the problematic area in the file by enclosing it in “<<<<<<<< HEAD” and “>>>>>>>>>>[other branch name]”
The contents after the first marker originate from your current working branch. After the angle brackets, Git tells us where (from which branch) the changes came from. A line with "=======" separates the two conflicting changes.
Our job is now to clean up these lines: when we're done, the file should look exactly as we want it to look. It can be necessary to consult the teammate who wrote the conflicting changes to decide which code is finally correct. Maybe it's yours, maybe it's his - or maybe a mixture between the two.
e.g. :
```
<<<<<<< HEAD:mergetest
This is my third line
=======
This is a fourth line I am adding
>>>>>>> 4e2b407f501b68f8588aa645acafffa0224b9b78:mergetest
```
`<<<<<<<`: Indicates the start of the lines that had a merge conflict. The first set of lines are the lines from the file that you were trying to merge the changes into.
`=======`: Indicates the break point used for comparison. Breaks up changes that user has committed (above) to changes coming from merge (below) to visually see the differences.
`>>>>>>>`: Indicates the end of the lines that had a merge conflict.
You resolve a conflict by editing the file to manually merge the parts of the file that git had trouble merging. This may mean discarding either your changes or someone else's or doing a mix of the two. You will also need to delete the '<<<<<<<', '=======', and '>>>>>>>' in the file.
Once you have resolved the conflict do `git add`. Do not forget to run the tests that you have to make sure you have resolved the conflict correctly.
You can also download different plugins depending on the IDE you are using for an easier way to resolve merge conflicts.
# How to undo a merge?
If you want to undo a merge then you can do `git merge —abort`
additional-material/git_workflow_scenarios/reverting-a-commit.md 0 → 100644
+ 41
- 0
  • View file @ 6e6c40a0

# Revert a commit
To revert a commit simply means to create a brand new commit that undoes all
the changes made in a previous one. It is like doing a ```CTRL + Z ``` on git.
Reversion is made easier in git because every commit you push to your remote repository has a unique alphanumeric key known as SHA(Secure Hash Algorithm) tied to it.
So this means you can revert any commit as long as you have the SHA.
But then, you have to be careful to reverse orderly so as not to mess your repository up.
To pick out the SHA of the specific commit we want to undo, a log of all the commits we have made so far would come in handy.
To get this, we would run the command:
```git log --oneline ```
Running the ```git log``` command alone would also give us the SHAs (in long form)
However using the ```--oneline ``` flag tells git that we want it displayed in a concise (one line) manner for easy read.
The first 7 characters displayed when you run this command is called the abbreviated commit hash.
For example, here is what I get when I run ```git log --oneline ``` on this repository:
```
389004d added spacing in title
c1b9fc1 Merge branch 'master' into tutorials
77eaafd added tutorial for reverting a commit
```
So this shows that with ```git log --oneline```, we can fetch a list of all the commits made on the repository together with the first 7 characters of its SHA.
Now, Let's assume I want to undo my commit of "added spacing in title", here are the steps I would take:
* Copy the SHA of the commit which, in this case is ```389004d```
* Then, run the command ```git revert 389004d```
This would pop open my text editor and prompt me to edit the commit message.
You can decide to leave the commit message as the default git message which starts with the word `Revert`
or you can also decide to customize the message to your liking.
* Next, I will save and close the text editor.
* Return to the command line.
* Run ```git push origin <branch-name>``` to push the reverted changes to Github.
And that is it, the change would be undone. In this case, my repository would be reverted to how it looked like in ```c1b9fc1```
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/paty22/patch-1

Menu

Explore Projects Groups Snippets