- Commit: Local to Repository
- Push: Repository to Remote (GitHub)
- Pull: Remote to Local (Get latest changes)
- Clone: Download the entire codebase
- Branching: Copy code, make changes, push to main for approval
- Forking: Create an online copy in your GitHub account, clone, make changes, and push/request changes to the original repository owner.
- Merging: Combining changes from one branch into another
- Pull Requests: Propose changes and notify others
- Issues: Track tasks, enhancements, bugs, or questions
- Gitignore: Specify files to be ignored
- Readme Files: Provide project information
- .git Folder: Stores Git’s internal data
- Rebase: Alternative to merging
- Conflict Resolution: Manage conflicts that may arise during collaboration.
Local Repository Setup:
- Create Python files locally or initialize a new repository using Github Desktop.
- Changes made locally are reflected in the file system.
Committing Changes (Local to Repo):
- Use Github Desktop’s Commit option to save changes to the local repository.
Remote Repository (GitHub):
- GitHub serves as the remote repository, an online server.
Pushing Changes (Repo to Remote):
- After committing changes locally, use the Push option in Github Desktop to update the remote server.
- This reflects the changes on GitHub, making them visible in the repositories section of the user profile.
Pulling Changes (Remote to Local):
- Utilize the
git pull
command to fetch and integrate changes from the remote repository into the local repository. - This keeps the local repository up-to-date with the latest changes from the remote repository.
Cloning:
- Cloning is like downloading the entire codebase, allowing you to have a local copy of the project.
Branching:
- Creating a branch involves copying the code to make changes separately. After making changes, you commit and push them to the main branch for approval.
Forking:
- Forking is creating an online copy of the entire code in your GitHub account.
- Clone the forked repository, make changes, and push them to your repository.
- Send a push/pull request to the owner of the original repository to inform them about the changes made.
Merging:
- After changes are made in a branch (feature branch, for example), they can be merged back into the main branch using pull requests or merging tools.
Pull Requests:
- Pull requests are initiated to propose changes to a repository.
- They provide a way for contributors to notify others about changes they’ve pushed to a branch in a repository.
Issues:
- Issues in GitHub can be used to track tasks, enhancements, bugs, or other kinds of questions.
Gitignore:
- Use a
.gitignore
file to specify intentionally untracked files that Git should ignore.
Readme Files:
- README files provide information about your project. They are often written in Markdown and serve as documentation.
.git Folder:
- The .git folder is where Git stores its internal data structures and configuration files.
Rebase:
- Rebase is a command used to integrate changes from one branch into another. It can be an alternative to merging.
Conflict Resolution:
- Conflicts may arise when changes are made to the same line in a file on both the local and remote repositories. Resolving conflicts is a crucial part of collaboration.
We first create our python files in our local folder or we can create a new repository using Github Desktop application on our system to create a folder for repository. Changes will reflect on our local file system as we can see a new folder showing in the location we create repository in.
Now when we create our python or environment variable files. Github desktop will keep track of the changes. Once we are done with all the changes we can use COMMIT (Commit to main) option on Github Desktop to save the changes.
Remote : Github remote which is online server. After we use COMMIT to make changes, they will reflect in our repo. but not on Github remote (online/server/github.com ) under repositories section of the user profile. To reflect these changes or see our repository published, we can use the PUSH option to update the Remote Server. We can use Publish to Repository .
COMMIT is for Local to Repo
PUSH is for Repo to Remote
PULL is for Remote Repo to Local – get latest changes
The git pull
command is used to fetch and integrate changes from a remote repository into your local repository. It essentially ensures that your local repository is up-to-date with the changes made in the connected remote repository, maintaining synchronization between them.
CLONE – its like downloading the code, when we
BRANCHING — when someone copies the code and make the changes , commit and push to main for approval.
FORKING – its like creating online copy of the entire code to your github account and then clone it from your account and make changes to the code, push changes to your repo. and then push/request the owner (original repo) telling them about the changes you have made to code.
Forking is similar to branching, its just online copy of the code first to your account.
How to Publish or Push your existing Code to a New Github Repository
Here are the steps to move your Python files from your local machine to the remote GitLab repository: Taking Local Folder name as SSW and Git Repo name as WWT
- Navigate to the SSW Folder:
- Open a terminal or command prompt.
- Change directory (
cd
) to the location where your Python files are stored.
syntax:cd /path/to/SSW
- Initialize a Git Repository:
- If the SSW folder is not already a Git repository, initialize it by running:
syntax:git init
- If the SSW folder is not already a Git repository, initialize it by running:
- Add GitLab Remote URL:
- Add the remote URL of your GitLab repository to your local repository. Replace
<YourGitLabUsername>
with your GitLab username and<YourRepositoryName>
with your repository name (WWT):
syntax:git remote add origin https://gitlab.com/<YourGitLabUsername>/WWT.git
- Add the remote URL of your GitLab repository to your local repository. Replace
- Add and Commit Files:
- Add all the files in the SSW folder to the local Git repository:
syntax:git add .
- Commit the changes:
syntax:git commit -m "Initial commit"
- Add all the files in the SSW folder to the local Git repository:
- Push to GitLab:
- Push the changes to the remote GitLab repository:
syntax:git push -u origin master
- If you are prompted for your GitLab username and password, provide them.
- Push the changes to the remote GitLab repository:
- Verify on GitLab:
- Open your GitLab repository in a web browser and verify that the Python files from your SSW folder are now in the WWT repository.
Now, your local Python files from the SSW folder should be successfully moved to your GitLab remote repository named WWT. Keep in mind that the specific commands may vary based on your operating system and Git configuration. Adjust them accordingly if needed.