Internet Engineering
First Assignment
This assignment was all about learning git.
-
To add current changes to last commit we use
git commit --amend -m "<new-message>". This command will update the last commit message with the new-message and appends the new commit changes to the last one without creating a new commit. -
In order to delete a specific file history in remote repo, we can use
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch <file-path>" HEAD. -
One of the ways of sharing some files with a teammate without pushing it to the main branch of the remote repository is using another branch. The other way is using
git stashand saving the changes in originating side, and then appling the changes usinggit applyin the other side.
First Method:
git checkout -b test
git add FileB.txt FileC.txt
git commit -m "<commit-message>"
git push origin test
Second Method:
<Sender>
touch FileB.txt --> A line is also added to this file
touch FileC.txt --> A line is also added to this file
git add .
git commit -m "Added files to be shared"
git stash
git stash show -p > shared.patch
git add shared.patch
git commit -m "Added patch file."
<Receiver>
git pull
git apply shared.patch
- Use
git rebaseto merge a commit from a branch to another. For example:
git checkout -b test2
git add FileA.txt
git commit -m "<commit-message>" --> This commit contains a hash
git push origin test2
git checkout master
git cherry-pick <commit-hash> --> For second commit.
git reabse test2
On this page
Languages
JavaScript41.9%Python38.2%HTML12.6%CSS7.2%
Contributors
Created October 21, 2021
Updated June 9, 2024