git commands

1

Basic commands:

git status

git add .

git commit -m "Message about recent change"

git push

2

git init: Initializes a new Git repository in the current directory.

git init

3

git clone [repository URL]: Clones a remote repository onto your local machine.

git clone https://github.com/example/repository.git

4

git add [file]: Adds a file or changes in a file to the staging area, preparing them to be committed.

git remote -v

git commit -m "[commit message]": Commits the staged changes to the local repository along with a commit message.

  1. git push: Pushes committed changes from your local repository to the remote repository.

  2. git pull: Fetches and merges changes from the remote repository into your local repository.

  3. git status: Displays the current status of the repository, including tracked/untracked files and changes.

  4. git log: Shows a history of commits in the repository, including commit hashes, authors, dates, and commit messages.

  5. git branch: Lists all branches in the repository.

  6. git checkout [branch name]: Switches to the specified branch.

  7. git merge [branch name]: Merges changes from the specified branch into the current branch.

  8. git stash: Temporarily shelves changes you've made to your working directory so you can work on something else, and then come back and re-apply them later.

  9. git reset: Resets the current HEAD to the specified state. It can be used to undo changes or move the HEAD to a different commit.

  10. git remote -v: Lists the remote repositories associated with the local repository along with their URLs.

  11. git fetch [remote]: Fetches changes from the remote repository without merging them into your working branch.

These examples demonstrate the usage of each Git command with basic arguments. Depending on your specific scenario and workflow, you may need to use additional options and flags with these commands. Always refer to the Git documentation or use git help [command] for more information on a particular command.


Got it. Since you are currently on the main branch and you want your changes to be reflected in the expert-feedback branch, you need to switch to the expert-feedback branch and merge the main branch into it. Here are the steps:

  1. Ensure your current changes are committed on the main branch:

  2. Fetch the latest changes from the remote repository:

  3. Switch to the expert-feedback branch:

  4. Merge the main branch into expert-feedback:

  5. Resolve any conflicts if there are any. After resolving, stage the resolved files:

  6. Commit the merge:

  7. Push the updated expert-feedback branch to the remote repository:

By following these steps, you will ensure that the changes made on the main branch are reflected in the expert-feedback branch.

To resolve the error related to the swap file, you need to handle the existing swap file properly. Here are the steps to follow:

  1. Delete the Swap File:

    • Since the recovery is not successful and the file is no longer available, you should delete the swap file to avoid future issues.

    • Use the following command to delete the swap file:

  2. Retry the Git Merge:

    • After deleting the swap file, you can retry the git merge origin/main command.

Here is a step-by-step guide:

  1. Open your terminal.

  2. Delete the swap file by running:

  3. Verify the deletion to ensure the swap file is removed:

    This command should return nothing if the file has been successfully deleted.

  4. Retry the git merge command:

These steps should clear the swap file conflict and allow you to proceed with the merge operation. If you still encounter issues, ensure that no other processes are running that might be interfering with your files.


Last updated